正在加载图片...
#include<stdio.h>源程序-统计成绩int main(void)I int count, i, n;double grade, total;printf("Enter n:"); scanf("%d", &n);total = O; count = O;Entern:4for(i = 1; i <= n; i++)(Entergrade#1:67printf("Enter grade #%d:", i);Entergrade#2:54scanf ("%lf", &grade);Entergrade#3: 88total = total + grade;Enter grade#4:73Grade average = 70.50if(grade< 60)此处省略elseNumberoffailures=1count++;7printf("Grade average = %.2fin", total/n);printf("Number of failures = %din", count);return O;i}#include <stdio.h> int main(void) { int count, i, n; double grade, total; printf("Enter n: "); scanf("%d", &n); total = 0; count = 0; for(i = 1; i <= n; i++){ printf("Enter grade #%d: ", i); scanf ("%lf", &grade); total = total + grade; if(grade < 60) count++; } printf("Grade average = %.2f\n", total/n); printf("Number of failures = %d\n", count); return 0; } 源程序-统计成绩 Enter n: 4 Enter grade #1: 67 Enter grade #2: 54 Enter grade #3: 88 Enter grade #4: 73 Grade average = 70.50 此处省略else Number of failures = 1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有