正在加载图片...
统计将“求一个数组所有元素 之和”写成函数,怎样 n算法: 写? n输入# include<stih *define N 30 统计 void maino 计算ntaN 输入 float sum=o, ave uts("please input %d score: 2, N); for(i=O: i< N: i++) scanf( %d &a[D sum+=a0: 输入并统计总分 ave=sum/N S4 printf"Sum=%.1f, Average=%.1f.\n", sum, ave)2 统计总分和平均分 ▪ 算法: ▪ 输入全班学生的成绩 ▪ 统计总分 ▪ 计算平均分 ▪ 输入总分和平均分 #include <stdio.h> #define N 30 void main() {int a[N],i; float sum=0,ave; puts(“please input %d score:”,N); for(i=0;i<N;i++) { scanf("%d",&a[i]); sum+=a[i]; }/*输入并统计总分*/ ave=sum/N; printf(" Sum=%.1f, Average=%.1f.\n", sum,ave); } •将“求一个数组所有元素 之和” 写成函数,怎样 写?
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有