标签:avg color for include div 类型 class code bsp
1 #include <stdio.h> 2 3 int main (void) 4 { 5 int i; 6 int sum = 0; 7 int cnt = 0; 8 float avg;//average平均值的缩写 9 10 for (i = 1; i<101; ++i) 11 { 12 if (i%2 == 1) 13 { 14 sum += i; 15 ++cnt; 16 } 17 } 18 avg = 1.0*sum /cnt; //1.0默认的是double类型 19 20 printf("sum = %d\n",sum); 21 printf("cnt = %d\n",cnt); 22 printf("avg = %f\n",avg); 23 24 25 return 0; 26 }
标签:avg color for include div 类型 class code bsp
原文地址:https://www.cnblogs.com/a188/p/12374063.html