fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. float heikin;
  6. int ten[100];
  7. int count, saikou, saitei, goukei;
  8. int i, t;
  9.  
  10. for (count = 0; count < 100; count++) {
  11. scanf("%d", &t);
  12. if (t == 999) break;
  13. ten[count] = t;
  14. }
  15. if (count < 1) {
  16. return 1;
  17. }
  18.  
  19. saikou = saitei = goukei = ten[0];
  20. for (i = 1; i < count; i++) {
  21. if (saikou < ten[i]) saikou = ten[i];
  22. if (ten[i] < saitei) saitei = ten[i];
  23. goukei += ten[i];
  24. }
  25. heikin = (float)goukei / count;
  26. printf("最高点:%d\n", saikou);
  27. printf("最低点:%d\n", saitei);
  28. printf("合計点:%d\n", goukei);
  29. printf("平均点:%f\n", heikin);
  30. for (i = 0; i < count; i++) {
  31. printf("%3d %+f\n", ten[i], ten[i] - heikin);
  32. }
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0.02s 1724KB
stdin
44
66
34
34
99
34
65
999
stdout
最高点:99
最低点:34
合計点:376
平均点:53.714287
 44 -9.714287
 66 +12.285713
 34 -19.714287
 34 -19.714287
 99 +45.285713
 34 -19.714287
 65 +11.285713