Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct grade //定義grade的資料結構
- {
- int eng_s,math_s;
- };
- struct student //定義student的資料結構
- {
- int student_id;
- char name[50];
- struct grade score; //定義1變數score,用到grade的資料結構
- };
- struct student student1,student2,student3;
- int main(void)
- {
- student1.student_id=10007142;
- strcpy(student1.name,"臨例會");
- student1.score.eng_s=80;
- student1.score.math_s=90;
- student2.student_id=10007143;
- strcpy(student2.name,"剪宏語");
- student2.score.eng_s=85;
- student2.score.math_s=80;
- student3.student_id=10007147;
- strcpy(student3.name,"成宴如");
- student3.score.eng_s=90;
- student3.score.math_s=70;
- printf("學號 姓名 英文分數 數學分數 \n");
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",student1.student_id,student1.name,student1.score.eng_s,student1.score.math_s);
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",student2.student_id,student2.name,student2.score.eng_s,student2.score.math_s);
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",student3.student_id,student3.name,student3.score.eng_s,student3.score.math_s);
- printf("\n================================================================\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement