2010年4月3日 星期六

99/04/04第五次作業

/* 程式範例: Ch2-3-3e.c */
#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=87;
jane.math = 78; /* 指定成員變數 */
jane.english = 65;
jane.computer = 55;
jane.accounting = 77;
john.math = 81; /* 指定成員變數 */
john.english = 82;
john.computer = 86;
john.accounting=84;
/* 顯示成績 */
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;
}

1 則留言:

JCCL 提到...

評分: ★★★☆▲
pls format your code!