%号输出

作者在 2009-11-03 20:28:42 发布以下内容

#include "stdio.h"
#include "stdlib.h"
#define N 100
int main(void)
{
    int n=0,i,num=0;
    float score[N],ave=0,per;
    printf("input the scores of class:\n");
    scanf("%f",&score[0]);
    while(score[num]>=0&&i<=N) /*以负数结束输入*/
    {
        num++;
        scanf("%f",&score[num]);
    }
    printf("output the scores of class:\n");
    for(i=0;i<num;i++)
    {
        printf("%.2f ",score[i]);
        if(score[i]>=60) n++;
        ave=ave+score[i];
        if(i%7==0)  putchar('\n');
    }
    ave=ave/num;
    per=(float)n/(float)num;
    printf("\nthe average of class is %.2f\npass students'number is %d\npass percent of
            class is %.1f% c\n",ave,n,per*100,37);
    system("pause");
    return 0;                       /* 37 输出% */
}

默认分类 | 阅读 725 次
文章评论,共0条
游客请输入验证码
文章分类