/*Ch2-3-1e.c */
#include 〈stdio.h〉
#include 〈stdlib.h〉
#include 〈string.h〉
struct student { //學生資料
int id;
char name[20];
char Class[10];
int math;
int english;
int computer;
int accounting;
};
int main() {//主程式
struct student std1; //宣告結構變數
struct student std2={2,"江大魚","會一A",55,65,75,75};
struct student std3;
struct student std4;
int total;
std1.id=1; //指定結構變數的值
strcpy(std1.name,"陳小安");
strcpy(std1.Class,"會一A");
std1.math=88;
std1.english=99;
std1.computer=91;
std1.accounting=68;
std3=std2; //指定敘述
std1.id=4; //指定結構變數的值
strcpy(std4.name,"李敬業");
strcpy(std4.Class,"會一A");
std4.math=61;
std4.english=62;
std4.computer=59;
std4.accounting=53;
printf("學號: %d\n", std1.id);//顯示學生資料
printf("姓名: %s\n", std1.name);
printf("班級: %s\n", std1.Class);
total=std1.math+std1.english+std1.computer+std1.accounting;
printf("成績總分: %d\n", total);
printf("--------------------\n");
printf("學號: %d\n", std2.id);
printf("姓名: %s\n", std2.name);
printf("班級: %s\n", std2.Class);
total=std2.math+std2.english+std2.computer+std2.accounting;
printf("成績總分: %d\n", total);
printf("--------------------\n");
printf("學號: %d\n", std3.id);
printf("姓名: %s\n", std3.name);
printf("班級: %s\n", std3.Class);
total=std3.math+std3.english+std3.computer+std3.accounting;
printf("成績總分: %d\n", total);
printf("--------------------\n");
printf("學號: %d\n", std4.id);
printf("姓名: %s\n", std4.name);
printf("班級: %s\n", std4.Class);
total=std4.math+std4.english+std4.computer+std4.accounting;
printf("成績總分: %d\n", total);
system("PAUSE");
return 0;
}
1 則留言:
#include ????
#include ????
#include ????
pls format your source code.
評分: ★★★☆
張貼留言