#include <stdio.h>
#define N100
int main(){
int n, a[N]={0};//n总人数
float m =0, k =0;//m及格人数 k优秀人数scanf("%d",&n);for(int i =0; i < n; i++){scanf("%d",&a[i]);if(a[i]>=60)
m++;if(a[i]>=85)
k++;}printf("%.0f%%\n",(m *100)/(n *1.0));//及格率printf("%.0f%%\n",(k *100)/(n *1.0));//优秀率return0;}
代码2(+0.5整数类型转换)
#include <stdio.h>
#define N100
int main(){
int n, a[N]={0};//n总人数
float m =0, k =0;//m及格人数 k优秀人数scanf("%d",&n);for(int i =0; i < n; i++){scanf("%d",&a[i]);if(a[i]>=60)
m++;if(a[i]>=85)
k++;}printf("%d%%\n",(int)(m*100/n+0.5));//及格率printf("%d%%\n",(int)(k*100/n+0.5));//优秀率return0;}