9.1#includeint
main()a=;
printf(
"no.: %d\n name: %s\n ***: %c\n addr: %s\n
",a.num,a.name,a.***,a.addr);
}
no.;9.210101
name:li lin
***:m
address:
123beijing road
--------------------------------process exited after
0.434 seconds with return value 0
請按任意鍵繼續. . .
#includeintmain();
struct
student student1,student2;
scanf(
"%d %s %f
",&student1.num,student1.name,&student1.score);
scanf(
"%d %s %f
",&student2.num,student2.name,&student2.score);
printf(
"the higher score is:\n");
if(student1.score>student2.score)
printf(
"%d %s %6.2f\n
",student1.num,student1.name,student1.score);
else
if(student2.score>student1.score)
printf(
"%d %s %6.2f\n
",student2.num,student2.name,student2.score);
else
}
10103,ling,98.0000009.3--------------------------------process exited after
0.3591 seconds with return value 0
請按任意鍵繼續. . .
#include#includestruct
person
leader[
3]=;
intmain()
printf(
"\nresult:\n");
for(i=0;i<3;i++)
printf(
"%5s:%d\n
",leader[i].name,leader[i].count);
return0;
}
li9.4lisun
zhang
zhabg
sunli
sunzhangli
result:
li:0zhang:
0sun:3
--------------------------------process exited after
85.36 seconds with return value 0
請按任意鍵繼續. . .
#include#includestruct student//
宣告結構體型別 struct person
;int
main()
,,,,};//
定義結構體陣列並初始化
struct
student temp;
const
int n=5
;
int i,j,k;//
定義常變數n
printf("
the order is:\n");
for(i=0;i1;i++)
for(i=0;i)
printf(
"%d,%s,%d
",stu[i].num,stu[i].name,stu[i].score);
printf("\n
");return0;
}
the order is9.5:10110,sun,010103,wang,010106,li,010101,zhang,010108,ling,0
--------------------------------process exited after
0.2652 seconds with return value 0
請按任意鍵繼續. . .
#include#includemain()
;struct student stu_1;//
定義struct student型別的變數stu_1
struct student *p;//
定義指向struct student型別資料的指標變數p
p=&stu_1;//
p指向stu—1
stu_1.num=10101;//
對結構體變數的成員賦值
strcpy(stu_1.name,"
li lin
");//
用字串複製函式給stu_1.name賦值
stu_1.***='m'
;stu_1.score=89
;printf(
"no.:%ld\nname:%s\n***:%c\nscore:%d\n
",stu_1.num,stu_1.name,stu_1.***,stu_1.score);
printf(
"no.:%ld\nname:%s\n***:%c\nscore:%d\n
",(*p).num,(*p).name,(*p).***,(*p).score);
return0;
}
no.name *** age9.610101,zhang,m,7810103,wang,m,9810106,li,m,86
--------------------------------process exited after
0.4277 seconds with return value 0
請按任意鍵繼續. . .
#include#includestruct student//
宣告結構體型別 struct person
;struct student stu[3]=,,};//
定義結構體陣列並初始化
main()
no.:101019.7name:li lin
***:m
score:
0no.:
10101
name:li lin
***:mscore:0
--------------------------------process exited after
0.4299 seconds with return value 0
請按任意鍵繼續. . .
#include#define n 3struct student//
宣告結構體型別 struct person
;int
main()
void input(struct
student stu)
}struct student max(struct
student stu)
void print(struct
student stud)
請輸入各學生的資訊:學號、姓名、三門課成績:總結:函式的定義和呼叫還需要練習。21 zh 36
3738
22 ji 25
2628
23 li 54
2312
成績最高的學生:
學號:21
姓名:zh
三門課成績:
36.0, 37.0, 38.0
平均成績:
37.00
--------------------------------process exited after
24.31 seconds with return value 0
請按任意鍵繼續. . .
抄寫例題作業1
例 9.1 includestruct student stu intmain 學號 1001 姓名 張三 性別 男 位址 哈爾濱 process exited after 0.01108 seconds with return value 0 請按任意鍵繼續.例 9.2 include inclu...
抄寫例題作業1
定義結構體變數a並初始化 printf no.d nname s n c naddress s n a.num,a.name,a.a.addr return0 no.10101 name li lin m address beijing road process exited after 0.095...
第四周作業的抄寫部分
有一種細菌分為a b兩個亞種,它們的外在特徵幾乎完全相同,僅僅在繁殖能力上有顯著差別,a亞種繁殖能力非常強,b亞種的繁殖能力很弱。在一次為時乙個小時的細菌繁殖實驗中,實驗員由 於疏忽把細菌培養皿搞亂了,請你編寫乙個程式,根據實驗結果,把兩個亞種的培養皿重新分成兩組。include using nam...