#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=89;
jane.math=78; //指定成員變數
jane.english=65;
jane.computer=55;
jane.accounting=81;
john.math=68; //指定成員變數
john.english=75;
john.computer=45;
john.accounting=89;
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);
system("PAUSE");
return 0;
}
評分: ★★★★▲
回覆刪除Excellent !