首页 > 代码库 > 抄写例题作业1
抄写例题作业1
//9.1.1 strust Date { int mouth; int day; int year; }; struct Student { int num; char name[20]; char sex; int age; structDate birthday; char addr[30]; };
//9.1.2 struct Student { int num; char name[20]; char sex; int age; float score; char addr[30]; }student1,student2;
//9.1.3 #include<stdio.h> int main() { struct Student { long int num; char name[20]; char sex; char addr[20]; }a={10101,"LI Lin",‘M‘,"123Beijing Road"}; printf("NO.:%ld\nname:%s\nsex:%c\naddress:%s\n",a.num,a.name,a.sex,a.addr); return 0; }
#include<stdio.h> //9.2.1 #include<string.h> struct Person { char name[20]; int count; } leader[3] = {"Li",0,"Zhang",0,"Sun",0}; int main() {int i,j; char leader_name[20]; for(i=1;i<=10;i++) { scang("%s",leader_name); for(j=0;j<3;j++) { if(stremp(leader_name,leader[j].name)==0)leader[j].count++; } } printf("\nResult:\n"); for(i=0;i<3;i++) printf("%5s:%d\n",leader[i].name,leader[i].count); return 0; }
//9.2 #include<stdio.h> int main() { struct Student { int num; char name[20]; float score; }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 printf("%d %s %6.2f\n",student1.num,student1.name,student1.score); return 0; }
抄了几道编译完成,不想抄了,看了一遍例题代码,挺简单的,再抄下去也没意义,眼睛疼心累
抄写例题作业1
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。