0
Help me again please
OK I am making the ticket office code. It takes an array of 5 ages, and my code figures out the lowest age(for example, 11), and then takes that number and makes it a percent, then that percent of 50(11% of 50). I don't understand what my code is doing wrong. #include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } int r=ages[0]; if (ages[1]<r) { r=ages[1]; } if (ages[2]<r) { r=ages[2]; } if (ages[3]<r) { r=ages[3]; } if (ages[4]<r) { r=ages[4]; } int e=r/100; int y=50; int h=y*e; int p=50-h; cout << p << endl; return 0; }
9 Réponses
0
cout<<float(50-0.5*r);
+ 1
You use 'int', use float in y
+ 1
in my code:
cout<<float(50-0.5*min);
+ 1
In your code min is 'r'
+ 1
You are welcome
+ 1
Enjoy !
#include <iostream>
using namespace std;
int main() {
int ages[5];
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
//your code goes here
float ma=ages[0];
for(int i=1;i<5;i++){
if (ages[i] < ma){
ma=ages[i];
}
}
cout << 50 - 50*ma/100;
return 0;
}
0
That did not work
0
would min be the percentage(in my code, e)?
0
Thank you!