Advertisement
hamaXD

Final 57 อนุบาลหมีน้อยยยย

Dec 6th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include<stdio.h>
  2. typedef struct {
  3.         float Maths, English, Thai, Total;
  4. }score;
  5. typedef struct {
  6.         score Student [50] ;
  7. }level;
  8.  
  9. void input_data (level C[ ]);
  10. float calculate_total (score S);
  11.  
  12. int main(){
  13.     // -----1
  14.     level MeeNoi[3];
  15.     input_data(MeeNoi);
  16.     int i,j;
  17.     for(i=0;i<3;i++)
  18.     {
  19.         for(j=0;j<5;j++)
  20.         {
  21.        
  22.             printf("sum=%.2f \n",calculate_total(MeeNoi[i].Student[j]));
  23.         }
  24.     }
  25.    
  26.     return 0;
  27. }
  28.  
  29.  
  30. void input_data (level c[]){
  31.     int i=0,j=0;
  32.     for(i=0;i<3;i++){
  33.         for(j=0;j<5;j++){
  34.             printf("Enter scores of MeeNoi[%d] Student[%d]:",i+1,j+1);
  35.             scanf("%f %f %f",&c[i].Student[j].Maths ,&c[i].Student[j].English ,&c[i].Student[j].Thai);
  36.             fflush(stdin); 
  37.         }
  38. }
  39.    
  40. }
  41.  
  42. float calculate_total (score s){
  43.     s.Total=s.Maths+s.English+s.Thai;
  44.     return s.Total;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement