/*Ch2-3-4e.c */
#include 〈stdio.h〉
#include 〈stdlib.h〉
#include 〈string.h〉
struct test {
int math;
int english;
int computer;
};
struct phone{
char phone1[10];
char phone2[10];
};
struct student {
int id;
char name[20];
struct test score;
struct phone callno;
};
int main() {
struct student std1;
struct student std2={2,"江小魚",{55,81,75},{"22334455","33445566"}};
int total;
std1.id=1;
strcpy(std1.name,"陳會安");
std1.score.math=78;
std1.score.english=66;
std1.score.computer=85;
strcpy(std1.callno.phone1,"55667788");
strcpy(std1.callno.phone2,"99887744");
printf("學號:%d\n",std1.id);
printf("姓名:%s\n",std1.name);
total=std1.score.math+std1.score.english+std1.score.computer;
printf("成績總分:%d\n", total);
printf("電話1:%s\n",std1.callno.phone1);
printf("電話2:%s\n",std1.callno.phone2);
printf("--------------------\n");
printf("學號:%d\n",std2.id);
printf("姓名:%s\n",std2.name);
total=std2.score.math+std2.score.english+std2.score.computer;
printf("成績總分:%d\n",total);
printf("電話1:%s\n",std2.callno.phone1);
printf("電話2:%s\n",std2.callno.phone2);
system("PAUSE");
return 0;
}
1 則留言:
#include
#include
#include
pls format your source code.
評分: ★★★☆
張貼留言