2 solutions

  • 0
    @ 2022-4-8 17:30:10
    
    //stl:int round(double x)   ----->四舍五入函数
    #include<bits/stdc++.h>
    using namespace std;
    int n,a,b,x;
    int main(){
    	//freopen("t.in","r",stdin);
    	//freopen("t.out","w",stdout);
        cin>>n;
        int tmp=n;
        while(tmp--){
        	cin>>x;
        	if(x>=60)b++;
        	if(x>=85)a++;
        }
        double ans1=(double)b/n*100;
        double ans2=(double)a/n*100;
        cout<<round(ans1)<<"%"<<endl;
    	cout<<round(ans2)<<"%";
    	return 0;
    }

    Information

    ID
    6482
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    101
    Accepted
    46
    Uploaded By