int main() { int s; int n; float avg; scanf("%d,%d",&s,&n); //特别注意的地方 // scanf("%d",&n); avg=s/n; printf("avg is %f ",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 ",s,n); return 0; }
./input.out | ./avg.out