#include <stdio.h> int main(int argc, char *argv[]) { int num[10],i,sum=0;/*10个实数,循环变量,和,平均*/ float avg = 0; printf("Please enter ten integers:\n"); for(i=0;i<10;i++)/*接受10个实数*/ { scanf("%d", &num[i]); } for(i=0;i<10;i++)/*计算和*/ { sum += num[i]; } avg = sum * 1.0 /10;/*平均*/ printf("avg:%.2f", avg); }
原文地址:https://www.cnblogs.com/black-/p/8998237.html
时间: 2024-10-10 23:23:41