int main() { int s; int n; float avg; scanf("%d,%d",&s,&n); //特别注意的地方 // scanf("%d",&n); avg=s/n; printf("avg is %f \n",avg); return 0; }
#include <stdio.h> int main() { int i; int n=0; int s=0; while(1) { scanf("%d",&i); if(i==0) { break; } n++; s+=i; } printf("%d,%d\n",s,n); return 0; }
./input.out | ./avg.out
时间: 2024-10-27 01:37:22