monoteen

error

Jun 7th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #pragma warning(disable:4996)
  3. #define MAX_STUDENT 5
  4.  
  5. struct student {
  6.     char name[20];
  7.     int korean, english, math;
  8.     double average;
  9. };
  10.  
  11. int main(void)
  12. {
  13.     struct student stdc[MAX_STUDENT];
  14.     double total_average = 0;
  15.     int i = 0;
  16.  
  17.     printf("%d명의 학생 정보를 입력하세요.\n", MAX_STUDENT);
  18.     for (i = 0; i < MAX_STUDENT; i++);
  19.     {
  20.         printf("이름 : ");
  21.         gets(stdc[i].name);
  22.         printf("국어, 영어, 수학 점수 : ");
  23.         scanf("%d %d %d", &stdc[i].korean, &stdc[i].english, &stdc[i].math);
  24.         stdc[i].average = (double)(stdc[i].korean + stdc[i].english + stdc[i].math) / 3;
  25.         total_average += stdc[i].average;
  26.     }
  27.  
  28.     total_average /= MAX_STUDENT;
  29.  
  30.     printf("\n이름        국어 영어 수학 평균\n");
  31.     for (i = 0; i<MAX_STUDENT; i++)
  32.     {
  33.         printf("%-10s %3d %3d &3d %6.2f\n", stdc[i].name, stdc[i].korean, stdc[i].english, stdc[i].math, stdc[i].average);
  34.     }
  35.     printf("전체 평균 : %6.2f", total_average);
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment