33. date=2005/6/15
34. 101 Zhang M 19 95.00 64.00 0.00
102 Wang F 18 92.00 97.00 0.00 103 Zha0 M 19 85.00 78.00 0.00 104 Li M 20 96.00 88.00 0.00 105 Gou M 19 91.00 96.00 0.00 106 Lin M 18 93.00 78.00 0.00 107 Ma F 18 98.00 97.00 0.00 108 Zhen M 21 89.00 93.00 0.00 109 Xu M 19 88.00 90.00 0.00 110 Mao F 18 94.00 90.00 0.00 ―――――――――――――――――――
101 Zhang M 19 95.00 64.00 79.50 102 Wang F 18 92.00 97.00 94.50 103 Zha0 M 19 85.00 78.00 81.50 104 Li M 20 96.00 88.00 92.00 105 Gou M 19 91.00 96.00 93.50 106 Lin M 18 93.00 78.00 85.50 107 Ma F 18 98.00 97.00 97.50 108 Zhen M 21 89.00 93.00 91.00 109 Xu M 19 88.00 90.00 89.00 110 Mao F 18 94.00 90.00 92.00 35. st= 101 Zhang M 19 89.00
t= 101 Zhang M 19 89.00 t= 101 Zhang M 19 95.00 st= 101 Zhang M 19 95.00 36. 0 7 15
0 1 15
37. No. Name Sex Age Score
103 Zhao M 19 85.70 109 Xu M 19 89.80 108 Zhen M 21 90.10 105 Gou M 19 90.20 106 Lin M 18 91.50 102 Wang F 18 92.40 110 Mao F 18 94.90 101 Zhang M 19 95.60 104 Li M 20 96.30 107 Ma F 17 98.70 38. sequence that persons leave the circle:
3 6 9 12 2 7 11 4 10 5 1 8 The last one is 13 四、程序设计题 1. 参考程序:
#include
#define N 5/*学生的人数*/
31
struct student { char num[6]; char name[8]; int score[4]; }stu[N]; void main()
{void print(struct student stu[6]); int i,j;
for (i=0;i {printf(\ printf(\ scanf(\ printf(\ scanf(\ for (j=0;j<3;j++) {printf(\ scanf(\ } printf(\} print(stu); } void print(struct student stu[6]) {int i,j; printf(\ for (i=0;i {printf(\ for (j=0;j<3;j++) printf(\ printf(\ } } 2. 编程思路: 定义结构体变量a、b、c和指针变量p。 当p指向a时,将a.score表示为(*p).score。 #include { typedef struct students { char name[10]; char sex; int score; }STDTS; STDTS s1={\’f’,78}, s2={\’m’,88},s3={\’f’,83}; STDTS *p=&s1; printf(\printf(\ (*p).name,(*p).sex,(*p).score); printf(\ s2.name,s2.sex,s2.score); 32 printf(\ s3.name,s3.sex,s3.score); if(p->score if(p->score p->name,p->sex,p->score); } 3. 编程思路 #include #define COUNTS struct counts void main( ) { int i, ch; COUNTS { char vowel; int num; }; static COUNTS figure[5]={‘a’,0,’e’,0,’i’,0,’o’,0,’u’,0}; printf(\请输入一行文字(以’!’结束):\\n\ ch=getchar( ); while ( ch!=‘!’ ) { switch ( ch ) { case ‘a’: case ‘A’: figure[0].num++; break; case ‘e’: case ‘E’: figure[1].num++; break; case ‘i’: case ‘I’: figure[2].num++; break; case ‘o’: case ‘O’: figure[3].num++; break; case ‘u’: case ‘U’: figure[4].num++; } ch=getchar( ); } printf(\输入的文字中各元音的个数分别为:\ for(i=0; i<5; i++) printf(\ } 4. 参考答案 #include enum weekdays{sun,mon,tue,wed,thu,fri,sat} today; printf(\请输入一整数(0~6):\ scanf(\ today=(enum weekdays)n; switch(today) { case mon: case tue: case wed: 33 case thu: case fri: printf(\工作日\ case sat: case sun: printf(\休息日\ default: printf(\输入错\ } } 5. 解题思路。显然,需要设一个数组,有3个元素,每个元素中的信息应包括候选人的姓名(字符型)和得票 数(整型),只有结构体类型才能胜任。据此编写程序如下: #include struct person { char name[20]; int count; } leader[3]={\void main( ) { int i,j;char leader_name[20]; for(i=0;i<=10;i++) { scanf(\ for(j=0;j<3;j++) if(strcmp(leader_name,leader[j].name)==0) leader[j].count++; } printf(\ for(i=0;i<3;i++) printf(\ 6. 分析:链表由头指针代表,要释放链表可以定义一个工作指针得到头指针,然后头指针和工作指针均不断下 移,同时释放结点。 void fun(struct node *head) {struct node *p; while(head!=NULL) {p=head; head=head->next; free(p); } } 7. 参考答案 #include NODE *create(int n); void insertlist(NODE *h, char *s); void deletelist(NODE *h, char *s); void printlist(NODE *h); void main() { char chose,sname[20]; 34 int n; NODE *head=NULL; for(;;) { system(\ printf(\创建单链表.\\n\ printf(\在单链表中插入结点.\\n\ printf(\在单链表中删除结点.\\n\ printf(\输出单链表.\\n\ printf(\退出.\\n\ printf(\请选择命令号:\ chose=getchar(); getchar(); switch(chose) { case ‘1’: printf(\输入结点个数: \ scanf(\ getchar(); head=create(n); break; case ‘2’: printf(\输入用于插入的姓名: \ gets(sname); insertlist(head,sname); break; case ‘3’: printf(\输入用于删除的姓名:\ gets(sname); deletelist(head,sname); break; case ‘4’: printlist(head); printf(\按任意键返回主菜单.\\n\ getch(); break; case ‘0’: exit(1); default: break; } } } NODE *create(int n) { NODE *p,*h; int i; char inbuf[10]; h=(NODE *)malloc(sizeof(NODE)); h->next=NULL; for(i=n;i>0;i--) { p=(NODE *)malloc(sizeof(NODE)); printf(\输入新结点值:\\n\ gets(p->name); gets(inbuf); p->score=atof(inbuf); p->next=h->next; h->next=p; } 35 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库程序设计上机实验课后答案(7)在线全文阅读。
相关推荐: