0
Ticket Office
in text office problem my code give the right answer on my compiler and give a wrong answer on sololearn compiler. my code: #include <iostream> using namespace std; int main() { int ages[5]; int nage=ages[5]; float min=nage; for (int i = 0; i < 5; ++i) { cin >> ages[i]; nage = ages[i]; if (nage < min){ min = nage; } } float d=50*(min/100); float total=50-d; cout << total << endl; return 0; }
1 ответ
+ 1
There is little mistake in your code
min value is always giving 0 because you are not storing first value in temp variable min
#include <iostream>
using namespace std;
int main() {
int ages[5];
//int nage=ages[5];
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
float min = ages[0];
for (int i = 0; i < 5; ++i) {
int nage = ages[i];
if (nage < min){
min = nage;
}
}
//cout << min;
//float d = 50 * (min / 100);
float total = 50 - 50 * min / 100;
cout << total << endl;
return 0;
}