Enter the names of two students of the school number and three scores and output

1  / * student input and displaying results * / 
2 # the include <stdio.h>
 . 3  
. 4  struct Student
 . 5  {
 . 6      char Number [ . 6 ];
 . 7      char name [ . 6 ];
 . 8      int   Score [ . 3 ];
 . 9 } STU [ 2 ];
 10  
. 11  void Output ( struct Student STU [ 2 ]);
 12 is  
13 is  void main ()
 14  {
 15      int I, J;
 16      for(I = 0 ; I < 2 ; I ++ )
 . 17      {
 18 is          the printf ( " Please enter student d achievement%: \ n- " , I + . 1 );
 . 19          the printf ( " Student ID: " );
 20 is          Scanf ( " % S " , STU [I] .number);
 21 is          the printf ( " name: " );
 22 is          Scanf ( " % S " , STU [I] .name);
 23 is          for (J = 0 ; J < . 3 ; J ++ )
 24         {
25             printf("成绩 %d.  ", j+1);
26             scanf("%d", &stu[i].score[j]);
27         }
28         printf("\n");
29     }
30     output(stu);
31 }
32 
33 void output(struct student stu[2])
34 {
35     int i, j;
36     printf("Results Studies No. Name 1 2 Results Results. 3 \ n- " );
 37 [      for (I = 0 ; I < 2 ; I ++ )
 38 is      {
 39          the printf ( " % -6S% -6S " , STU [I] .number, STU [ I] .name);
 40          for (J = 0 ; J < . 3 ; J ++ )
 41 is              the printf ( " % -8D " , STU [I] .score [J]);
 42 is          the printf ( " \ n- " );
 43 is      }
 44 }

 

Guess you like

Origin www.cnblogs.com/liugangjiayou/p/11616370.html