Răspuns :
Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int a, b, x;
cin >> a >> b;
cout << "Sunt necesare " << ( b - 1 ) / a + 1 << " sticle de a litri pentru a umple una cu " << b << " litri" << endl;
cin >> a >> b >> x;
if ( a <= x && x <= b )
cout << x << " apartine intervalului [" << a << ',' << b << ']' << endl;
else
cout << x << " nu apartine intervalului [" << a << ',' << b << ']' << endl;
cin >> a >> b;
if ( a < 0 && b > 0 || b < 0 && a > 0 )
cout << "semnul este -" << endl;
else
cout << "semnul este +" << endl;
return 0;
}
Explicație:
Daca voiai fara scris, main-ul arata asa:
int main() {
int a, b, x;
cin >> a >> b;
cout << ( b - 1 ) / a + 1 << endl;
cin >> a >> b >> x;
if ( a <= x && x <= b )
cout << 1 << endl;
else
cout << 0 << endl;
cin >> a >> b;
if ( a < 0 && b > 0 || b < 0 && a > 0 )
cout << "-" << endl;
else
cout << "+" << endl;
return 0;
}