Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* 主程式 */
- int main()
- {
- struct test /* 宣告結構 */
- {
- int math;
- int english;
- int computer;
- int accounting;
- };
- typedef struct test score; /* 定義新型態 */
- score joe, jane, john; /* 使用新型態變數宣告 */
- joe.math = 80; /* 指定成員變數 */
- joe.english = 85;
- joe.computer = 83;
- joe.accounting = 82;
- jane.math = 78; /* 指定成員變數 */
- jane.english = 65;
- jane.computer = 55;
- jane.accounting = 82;
- john.math = 70; /* 指定成員變數 */
- john.english = 80;
- john.computer = 90;
- john.accounting = 100;
- printf("姓名: Joe\n"); /* 顯示成績 */
- printf("數學: %d\n", joe.math);
- printf("英文: %d\n", joe.english);
- printf("電腦: %d\n", joe.computer);
- printf("會計: %d\n", joe.accounting);
- printf("=================\n");
- printf("姓名: Jane\n");
- printf("數學: %d\n", jane.math);
- printf("英文: %d\n", jane.english);
- printf("電腦: %d\n", jane.computer);
- printf("會計: %d\n", jane.accounting);
- printf("=================\n");
- printf("姓名: John\n");
- printf("數學: %d\n", john.math);
- printf("英文: %d\n", john.english);
- printf("電腦: %d\n", john.computer);
- printf("會計: %d\n", john.accounting);
- printf("=================\n");
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment