MUstar

IoT C언어 0425 - 도전실전1

Apr 25th, 2017
30
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int total(int kor, int eng, int mat);
  3. double average(int tot);
  4. void print_title(void);
  5.  
  6. int main(void)
  7. {  
  8.     int s1,s2,s3,sum;
  9.     double avg;
  10.     printf("# 세 과목의 점수 입력 : ");
  11.     scanf("%d%d%d",&s1,&s2,&s3);
  12.     sum = total(s1,s2,s3);
  13.     avg = average(sum);
  14.     print_title();
  15.     printf("%6d%6d%7d%7d%7.1lf\n",s1,s2,s3,sum,avg);
  16.     return 0;
  17. }
  18.  
  19. int total(int kor, int eng, int mat)
  20. {
  21.     int t1;
  22.     t1 = kor + eng + mat;
  23.     return t1;
  24. }
  25. double average(int tot)
  26. {
  27.     double t2;
  28.     t2 = tot/3.0;
  29.     return t2;
  30. }
  31. void print_title(void)
  32. {
  33. printf("       =====< 성적표 >=====       \n\n\n");
  34. printf("----------------------------------\n");
  35. printf("  국어   영어   수학   총점   평균  \n");
  36. printf("----------------------------------\n");
  37. }
RAW Paste Data