Загрузить файлы в «/»
This commit is contained in:
79
task2.cpp
79
task2.cpp
@@ -1,39 +1,40 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
double ab;
|
||||
double bc;
|
||||
double weight;
|
||||
cout << "Distance A-B: ";
|
||||
cin >> ab;
|
||||
cout << "Distance B-C: ";
|
||||
cin >> bc;
|
||||
cout << "Cargo weight: ";
|
||||
cin >> weight;
|
||||
|
||||
double fuel;
|
||||
if (weight <= 500) fuel = 1;
|
||||
else if (weight <= 1000) fuel = 4;
|
||||
else if (weight <= 1500) fuel = 7;
|
||||
else if (weight <= 2000) fuel = 9;
|
||||
else {
|
||||
cout << "The airplane cannot lift such a load!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double nAB = ab * fuel;
|
||||
double nBC = bc * fuel;
|
||||
|
||||
if (nAB > 300) {
|
||||
cout << "It is impossible to reach point B by flight." << endl;
|
||||
}
|
||||
else if (nBC > 300) {
|
||||
cout << "It is impossible to fly from B to C." << endl;
|
||||
}
|
||||
else {
|
||||
double fill = max(0.0, nBC - (300 - nAB));
|
||||
cout << "Minimum refuel at B: " << fill << " liters." << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//#include <iostream>
|
||||
//
|
||||
//using namespace std;
|
||||
//
|
||||
//int main() {
|
||||
// long long x;
|
||||
// cout << "Number: ";
|
||||
// cin >> x;
|
||||
// long long y;
|
||||
// y = llabs(x);
|
||||
// if (y == 0) {
|
||||
// cout << "Digits: 1\n";
|
||||
// cout << "Sum: 0\n";
|
||||
// cout << "Avg: 0\n";
|
||||
// cout << "Zeros: 1\n";
|
||||
// return 0;
|
||||
// }
|
||||
// int c;
|
||||
// c = 0;
|
||||
// int s;
|
||||
// s = 0;
|
||||
// int z;
|
||||
// z = 0;
|
||||
// while (y > 0) {
|
||||
// int d;
|
||||
// d = y % 10;
|
||||
// s += d;
|
||||
// if (d == 0) z++;
|
||||
// y /= 10;
|
||||
// c++;
|
||||
// }
|
||||
// double a;
|
||||
// a = (c == 0) ? 0.0 : (double)s / c;
|
||||
// cout << "Digits: " << c << "\n";
|
||||
// cout << "Sum: " << s << "\n";
|
||||
// cout << "Avg: " << a << "\n";
|
||||
// cout << "Zeros: " << z << "\n";
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user