0
i was Solvin module 36 ticket counter in c++, but idk why min is not working correctly, any suggestions?
#include <iostream> using namespace std; int main() { int ages[5]; int min=0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; if(min>ages[i]) min =ages[i]; } //your code goes here cout<< 50 - min*0.5; return 0; }
6 Antworten
+ 2
Read <ages>[0] and assign it as <min>. Do this before starting loop.
cin >> ages[0];
int min = ages[0];
Use 1 instead of 0 in your for..loop initialization.
for( int i = 1; i < 5; i++ )
{
// loop body
}
+ 2
Martin Taylor,
Related account maybe?
+ 1
Martin Taylor,
It's okay, looks like the guy's got banned recently ...
+ 1
This may be help you :
#include <iostream>
using namespace std;
int main() {
int ages[5];
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
double youngest = ages[0];
for (int a = 0; a <5; ++a)
{
if(youngest>ages[a])
{
youngest = ages[a];
}
}
double prezzo = 50 - (50*youngest/100);
cout << prezzo;
return 0;
}