構造1

1  / * 通讯录排序* / 
2の#include <stdio.hに>
 3  のstruct 誕生日{
 4  int型の年、mooth、日;
5  }。
6  構造体学生{
 7  のint TEL。
8  文字の名前[ 20 ]。
9  構造体の誕生日の誕生。
10  
11  }。
12  
13  INTメイン(ボイド14 { 構造体学生[ 20 ]。
15  
16  
17  int型N、T、I、J。
18  
19のscanf(" %d個"、&N)
20  のために(i = 0 ; iがn <; iは++ ){
 21のprintf(" 入力学生:\ n " );
22のscanf(" %sの%D%D%D%D "、[I] .nameの、&​​[I]ドットテル、&​​[I] .birth.year、&[I] .birth.mooth、&[ I] .birth.day);}
 23  (i = 1 ; iがn <; iは++ ){
 24  (J = 0 ; J <NI; J ++ ){
 25  であれば([J] .birth.year> A [J + 1 ] .birth.year){
 26、T =[J] .birth.year。
27 [J] .birth.year = A [J + 1 ] .birth.year。
28 [J + 1 ] .birth.year = T;}}}
 29  であれば([J] .birth.year == A [J + 1 ] .birth.year){
 30  であれば([J] .birth。 mooth> [J + 1 ] .birth.mooth)
 31 T = [J] .birth.mooth。
32 [J] .birth.mooth = A [J + 1 ] .birth.mooth。
33 [J + 1 ] .birth.mooth = T。
34のprintf(" 输出排序后的信息\ n " ;})
 35  (i = 0 ; iがN <; I ++){
 36のprintf(" %sの\ T%D \ T%D \ T%D \ T%D \ n " 、[I] .nameの、[I]ドットテル、[I] .birth.year 、[I] .birth.mooth、[I] .birth.day);}
 37  リターン 0 38 }
1  / * プレス統計学生の性能レベル* / 
2の#include <stdio.hの>
 3。の#include < 文字列・H>
 4。 
5。 int型 set_grade(構造体学生学生[ 10 ]、INT N-);
 6  
。7  構造体学生{
 8。 INT NUM ;
 9  チャー名[ 10 ]; 
 10  ダブルスコア; 
 11  チャーグレード; 
 12である };
 13である INT main()の
 14  {
 15  int型N-、Iは、COUNT。
16  
17。のprintf(" 統計学生の数を入力してください" ); 
 18は scanfの(" %のD "、およびN-)
 。19  構造体。生徒の生徒[ 10 ];
 20である ため(I = 0 ; Iは、N <; Iは++ ){
 21であるのprintf (" 名前:" );
 22は scanfの(" %S "、&学生[I] .nameの);
 23である(printfの" 学生ID:" );
 24 scanfの(" %のD "、&学生[I] .nu​​m);
 25のprintf(" 結果:" );
 26は scanfの(" %のLF "、& 学生[I] .score);
 27  
28 COUNT = set_grade(学生、N-); 
 29  }
 30  のために( = I 0、I <N - 、Iは++ ){
 31である 
32のprintf(" 学生ID:%dの名:%Sグレード:C%は\ N- " 、学生[I] .nu​​m、学生[I] .nameの、学生[I。。。 ] .grade); 
 33である }
 34は、 
35のprintfは(" 失敗グレード番号である:D%\ N- " 、COUNT) 
 36  リターン 0;
37  }
 38  のint set_grade(構造体の学生の学生[ 10 ]、int型N) 
 39  {
 40  int型 I、=カウント0 41  のために(i = 0 ; iがn <; iは++ 42  
43  {
 44  であれば(学生[I] .score < 60 ){
 45人の学生[I] .grade = ' D ' 46  
47数++ ;
48  } 
 49  、他の 場合(学生[i]が.score < 70&&学生[I] .score> = 60 ){
 50人の学生[I] .grade = ' C ' 51  }
 52  他の 場合(学生[I] .score < 85人の &&学生[I] .score> = 70 ){
 53人の学生[I] .grade = ' B ' 54  }
 55  他の 場合(学生[I] .score <= 100 &&学生[I] .score> = 85 ){
 56人の学生[I] .grade = ' A ' 57  }
 58  }
 59  リターンカウント; 
60 }

おすすめ

転載: www.cnblogs.com/wagb/p/yyyyc.html