Advertisement
kk258966

12/05 進階程式設計 練習二

Dec 5th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. struct student  //定義student的資料結構
  6. {
  7.   int student_id;
  8.   char name[50];
  9.   int score;      
  10. };
  11. struct student student1,student2,student3; //定義3個資料結構變數
  12.  
  13. int main(void)
  14. {
  15.     student1.student_id=10007142;
  16.     strcpy(student1.name,"臨例會");
  17.     student1.score=94;
  18.    
  19.    
  20.     printf("學號       姓名    分數\t\n");
  21.     printf("%d    %s  %d\n",student1.student_id,student1.name,student1.score);
  22.    
  23.     student2.student_id=10007143;
  24.     strcpy(student2.name,"剪宏語");
  25.     student2.score=95;
  26.    
  27.    
  28.  
  29.     printf("%d    %s  %d\n",student2.student_id,student2.name,student2.score);
  30.    
  31.     student3.student_id=10007147;
  32.     strcpy(student3.name,"成宴如");
  33.     student3.score=96;
  34.    
  35.    
  36.    
  37.     printf("%d    %s  %d\n",student3.student_id,student3.name,student3.score);
  38.    
  39.     system("pause");
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement