Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define size 100
- struct student
- {
- int student_id;
- char name[50];
- int score[20];
- };
- struct student s_grade[size];
- int main(void)
- {
- s_grade[1].student_id=10007142;
- strcpy(s_grade[1].name,"臨例會");
- s_grade[1].score[1]=80;
- s_grade[1].score[2]=90;
- s_grade[2].student_id=10007143;
- strcpy(s_grade[2].name,"剪宏語");
- s_grade[2].score[1]=85;
- s_grade[2].score[2]=80;
- s_grade[3].student_id=10007147;
- strcpy(s_grade[3].name,"成宴如");
- s_grade[3].score[1]=90;
- s_grade[3].score[2]=70;
- printf("土法煉鋼印出\n");
- printf("學號 姓名 英文分數 數學分數 \n");
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",s_grade[1].student_id,s_grade[1].name,s_grade[1].score[1],s_grade[1].score[2]);
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",s_grade[2].student_id,s_grade[2].name,s_grade[2].score[1],s_grade[2].score[2]);
- printf("\n================================================================\n");
- printf("%d %s %8d%12d",s_grade[3].student_id,s_grade[3].name,s_grade[3].score[1],s_grade[3].score[2]);
- printf("\n================================================================\n");
- printf("迴圈印出\n");
- int i;
- for (i=1;i<=3;i++)
- {
- printf("%d %s %8d%12d",s_grade[i].student_id,s_grade[i].name,s_grade[i].score[1],s_grade[i].score[2]);
- printf("\n================================================================\n");
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement