i was Solvin module 36 ticket counter in c++, but idk why min is not working correctly, any suggestions? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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; }

30th Mar 2021, 6:15 AM
Ritik Mehra
Ritik Mehra - avatar
4 Respostas
+ 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 }
30th Mar 2021, 6:34 AM
Ipang
+ 2
Martin Taylor, Related account maybe?
30th Mar 2021, 9:51 AM
Ipang
+ 1
Martin Taylor, It's okay, looks like the guy's got banned recently ...
30th Mar 2021, 2:39 PM
Ipang
+ 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; }
1st Apr 2021, 1:32 AM
ā¤ļøšŸ˜PreranašŸ˜ā¤ļø
ā¤ļøšŸ˜PreranašŸ˜ā¤ļø - avatar