problem link-click here
accepted code:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int n;
double c,i=0;
cin>>c;
while(i<c)
{
cin>>n;
int marks[n+10];
double avg,j=0,sum=0,ans;
for(int k=0;k<n;k++)
{
cin>>marks[k];
sum=sum+marks[k];
}
avg=sum/n;
for(int l=0;l<n;l++)
{
if(marks[l]>avg)
{
j++;
}
}
ans=(j*100)/n;
cout<<fixed<<setprecision(3)<<ans<<"%"<<endl;
i++;
}
return 0;
}
accepted code:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int n;
double c,i=0;
cin>>c;
while(i<c)
{
cin>>n;
int marks[n+10];
double avg,j=0,sum=0,ans;
for(int k=0;k<n;k++)
{
cin>>marks[k];
sum=sum+marks[k];
}
avg=sum/n;
for(int l=0;l<n;l++)
{
if(marks[l]>avg)
{
j++;
}
}
ans=(j*100)/n;
cout<<fixed<<setprecision(3)<<ans<<"%"<<endl;
i++;
}
return 0;
}
No comments:
Post a Comment