Guest User

Untitled

a guest
Jan 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. /* 主程式 */
  4. int main()
  5. {
  6. struct test /* 宣告結構 */
  7. {
  8. int math;
  9. int english;
  10. int computer;
  11. int accounting;
  12. };
  13. typedef struct test score; /* 定義新型態 */
  14. score joe, jane, john; /* 使用新型態變數宣告 */
  15.  
  16. joe.math = 80; /* 指定成員變數 */
  17. joe.english = 85;
  18. joe.computer = 83;
  19. joe.accounting = 82;
  20.  
  21. jane.math = 78; /* 指定成員變數 */
  22. jane.english = 65;
  23. jane.computer = 55;
  24. jane.accounting = 82;
  25.  
  26. john.math = 70; /* 指定成員變數 */
  27. john.english = 80;
  28. john.computer = 90;
  29. john.accounting = 100;
  30.  
  31. printf("姓名: Joe\n"); /* 顯示成績 */
  32. printf("數學: %d\n", joe.math);
  33. printf("英文: %d\n", joe.english);
  34. printf("電腦: %d\n", joe.computer);
  35. printf("會計: %d\n", joe.accounting);
  36. printf("=================\n");
  37. printf("姓名: Jane\n");
  38. printf("數學: %d\n", jane.math);
  39. printf("英文: %d\n", jane.english);
  40. printf("電腦: %d\n", jane.computer);
  41. printf("會計: %d\n", jane.accounting);
  42. printf("=================\n");
  43. printf("姓名: John\n");
  44. printf("數學: %d\n", john.math);
  45. printf("英文: %d\n", john.english);
  46. printf("電腦: %d\n", john.computer);
  47. printf("會計: %d\n", john.accounting);
  48. printf("=================\n");
  49.  
  50. system("PAUSE");
  51. return 0;
  52. }
Add Comment
Please, Sign In to add comment