+ 2
How can i solve this problem?
Please help me about this code? I found wrong answer on test case 1 and 3. My code link: https://code.sololearn.com/cE8HlcG87gz0/?ref=app Problem: https://www.sololearn.com/coach/904?ref=app Tell me,where is the wrong.
7 Réponses
+ 2
//My code
#include <iostream>
using namespace std;
int main() {
int ages[5],min;
//double total=0;
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
//your code goes here
double total=0.0;
min=ages[0];
for(int i=0;i<5;i++){
if(ages[i]<min){
min=ages[i];
}
}
total=50.0-50*(min/100.0);
cout<<total;
return 0;
}
You just need to calculate the min and the discount should be min%. Read the question once again..!!
+ 3
Remove the line
total = .... Inside the loop.
And write this outside of loop
total=50.0-(min*50)/100.0;
+ 2
Share code link .
+ 1
The links you shared, both are the links of question..
+ 1
sarada lakshmi
Thanks my loving friend.
Code accepted.
Also thank you for helping.
+ 1
SAYED🇧🇩🇵🇸
আপনাকে অনেক অনেক ধন্যবাদ -সাহায্য করার জন্য।❣️❣️
0
//My code
#include <iostream>
using namespace std;
int main() {
int ages[5],min;
//double total=0;
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
//your code goes here
double total=0.0;
min=ages[0];
for(int i=0;i<5;i++){
if(ages[i]<min){
min=ages[i];
total=50.0-50*(ages[i]/100.0);
}
}
cout<<total;
return 0;
}