Structure 1

 1 /*通讯录排序*/
 2 #include<stdio.h>
 3 struct birthday {
 4 int year,mooth,day;
 5 };
 6 struct student {
 7 int tel;
 8 char name[20];
 9 struct birthday birth;
10 
11 };
12 
13 int main(void)
14 {struct student a[20];
15 
16 
17 int n,t,i,j;
18 
19 scanf("%d",&n);
20 for(i=0;i<n;i++){
21 printf("Input student:\n");
22 scanf("%s%d%d%d%d",a[i].name,&a[i].tel,&a[i].birth.year,&a[i].birth.mooth,&a[i].birth.day);}
23 for(i=1;i<n;i++){
24 for(j=0;j<n-i;j++){
25 if(a[j].birth.year>a[j+1].birth.year){
26 t=a[j].birth.year;
27 a[j].birth.year=a[j+1].birth.year;
28 a[j+1].birth.year=t;}}}
29 if(a[j].birth.year==a[j+1].birth.year){
30 if(a[j].birth.mooth>a[j+1].birth.mooth)
31 t=a[j].birth.mooth;
32 a[j].birth.mooth=a[j+1].birth.mooth;
33 a[j+1].birth.mooth=t;
34 printf("输出排序后的信息\n");}
35 for(i=0;i<n;i++){
36 printf("%s\t%d\t%d\t%d\t%d\n",a[i].name,a[i].tel,a[i].birth.year,a[i].birth.mooth,a[i].birth.day);}
37 return 0;
38 }
1  / * Press statistical student performance level * / 
2 #include <stdio.h>
 . 3 #include < String .h>
 . 4  
. 5  int set_grade ( struct Student Students. [ 10 ], int n-);
 . 6  
. 7  struct Student {
 . 8  int NUM ;
 . 9  char name [ 10 ]; 
 10  Double Score; 
 . 11  char Grade; 
 12 is  };
 13 is  int main ()
 14  {
 15  int n-, I, COUNT;
16  
. 17 the printf ( " Enter the number of statistical Student: " ); 
 18 is Scanf ( " % D " , & n-);
 . 19  struct Student Students. [ 10 ];
 20 is  for (I = 0 ; I <n-; I ++ ) {
 21 is the printf ( " name: " );
 22 is Scanf ( " % S " , & Students. [I] .name);
 23 is the printf ( " Student ID: " );
 24 Scanf ( " % D " , &Students. [I] .num);
 25 the printf ( " Results: " );
 26 is Scanf ( " % LF " , & Students. [I] .score);
 27  
28 COUNT = set_grade (Students., n-); 
 29  }
 30  for ( = I 0 ; I <n-; I ++ ) {
 31 is  
32 the printf ( " Student ID:% d name:% s grade: C% \ n- " , Students. [I] .num, Students. [I] .name, Students. [I ] .grade); 
 33 is  }
 34 is  
35 the printf ( " failing grade number is: D% \ n- " , COUNT); 
 36  return  0;
37 }
38 int set_grade(struct student students[10],int n) 
39 {
40 int i,count=0;
41 for(i=0;i<n;i++)
42 
43 {
44 if(students[i].score<60){
45 students[i].grade='D';
46 
47 count++;
48 } 
49 else if(students[i].score<70&&students[i].score>=60){
50 students[i].grade='C';
51 }
52 else if(students[i].score<85&&students[i].score>=70){
53 students[i].grade='B';
54 }
55 else if(students[i].score<=100&&students[i].score>=85){
56 students[i].grade='A';
57 }
58 }
59 return count; 
60 }

Guess you like

Origin www.cnblogs.com/wagb/p/yyyyc.html