Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. void input_scores(float score[], int n)
  5. {
  6. int c;
  7. printf("\n\n");
  8. printf("점수를 입력하세요.\n");
  9. for (c = 0; c<n; c++)
  10. {
  11. scanf("%f", &score[c]);
  12. }
  13. }
  14.  
  15.  
  16. int limit;
  17. float max = 0.0;
  18. float min = 100.0;
  19. float sum = 0.0;
  20.  
  21. float max_score(float score[], int n)
  22. {
  23. limit = n - 1;
  24. n = 0;
  25.  
  26. if (score[n] > max)
  27. {
  28. max = score[n];
  29. n++;
  30. return max_score(score, n);
  31. }
  32.  
  33. if (n == limit)
  34. return max;
  35.  
  36. }
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. /*
  46. float min_score(float score[], int n)
  47. {
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
  59. float sum_scores(float score[], int n)
  60. {
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. }
  68. */
  69.  
  70.  
  71. void print_result(float max/*, float min, float sum, float mean*/)
  72. {
  73. printf("**************************\n");
  74. printf("최고점수: %f\n", max);
  75. /*printf("최저점수: %f\n", min);
  76. printf("합계점수: %f\n", sum);
  77. printf("평균점수: %f\n", mean);*/
  78. printf("**************************\n");
  79. }
  80.  
  81.  
  82. void main()
  83. {
  84. int n;
  85. float score[30];
  86. float max, min, sum, mean;
  87.  
  88. printf("학생수? ");
  89. scanf("%d", &n);
  90.  
  91. input_scores(score, n);
  92.  
  93. max = max_score(score, n);
  94. /*min = min_score(score, n);
  95. sum = sum_scores(score, n);
  96. mean = sum / (float)n;*/
  97.  
  98. print_result(max/*, min, sum, mean*/);
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement