ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:16.43KB ,
资源ID:8061889      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8061889.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(经典C程序100例7180.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

经典C程序100例7180.docx

1、经典C程序100例7180经典c程序100例=71-80【程序71】题目:编写input()和output()函数输入,输出5个学生的数据记录。1.程序分析:2.程序源代码:#define N 5struct student char num6;char name8;int score4; stuN;input(stu)struct student stu; int i,j;for(i=0;iN;i+) printf(n please input %d of %dn,i+1,N);printf(num: );scanf(%s,stui.num);printf(name: );scanf(%s,

2、stui.name);for(j=0;j3;j+) printf(score %d.,j+1);scanf(%d,&stui.scorej);printf(n);print(stu)struct student stu; int i,j;printf(nNo. Name Sco1 Sco2 Sco3n);for(i=0;iN;i+) printf(%-6s%-10s,stui.num,stui.name);for(j=0;jn);for(i=0;idata=num;ptr-next=(link)malloc(sizeof(node);if(i=4) ptr-next=NULL;else ptr

3、=ptr-next;ptr=head;while(ptr!=NULL) printf(The value is =%dn,ptr-data);ptr=ptr-next;=【程序73】题目:反向输出一个链表。1.程序分析:2.程序源代码:/*reverse output a list*/#include stdlib.h#include stdio.hstruct list int data;struct list *next;typedef struct list node;typedef node *link;void main() link ptr,head,tail;int num,i;

4、tail=(link)malloc(sizeof(node);tail-next=NULL;ptr=tail;printf(nplease input 5 data=n);for(i=0;idata=num;head=(link)malloc(sizeof(node);head-next=ptr;ptr=head;ptr=ptr-next;while(ptr!=NULL) printf(The value is =%dn,ptr-data);ptr=ptr-next;=【程序74】题目:连接两个链表。1.程序分析:2.程序源代码:#include stdlib.h#include stdio.

5、hstruct list int data;struct list *next;typedef struct list node;typedef node *link;link delete_node(link pointer,link tmp)if (tmp=NULL) /*delete first node*/return pointer-next;else if(tmp-next-next=NULL)/*delete last node*/tmp-next=NULL;else /*delete the other node*/tmp-next=tmp-next-next;return p

6、ointer;void selection_sort(link pointer,int num) link tmp,btmp;int i,min;for(i=0;idata;btmp=NULL;while(tmp-next) if(mintmp-next-data)min=tmp-next-data;btmp=tmp;tmp=tmp-next;printf(40: %dn,min);pointer=delete_node(pointer,btmp);link create_list(int array,int num) link tmp1,tmp2,pointer;int i;pointer=

7、(link)malloc(sizeof(node);pointer-data=array0;tmp1=pointer;for(i=1;inext=NULL;tmp2-data=arrayi;tmp1-next=tmp2;tmp1=tmp1-next;return pointer;link concatenate(link pointer1,link pointer2) link tmp;tmp=pointer1;while(tmp-next)tmp=tmp-next;tmp-next=pointer2;return pointer1;void main(void) int arr1=3,12,

8、8,9,11;link ptr;ptr=create_list(arr1,5);selection_sort(ptr,5);=【程序75】题目:放松一下,算一道简单的题目。1.程序分析:2.程序源代码:main()int i,n;for(i=1;i1)break;if(n%2=0)printf(Even=);sum=dcall(peven,n);elseprintf(Odd=);sum=dcall(podd,n);printf(%f,sum);float peven(int n)float s;int i;s=1;for(i=2;i=n;i+=2)s+=1/(float)i;return(s)

9、;float podd(n)int n;float s;int i;s=0;for(i=1;i=n;i+=2)s+=1/(float)i;return(s);float dcall(fp,n)float (*fp)();int n;float s;s=(*fp)(n);return(s);=【程序77】题目:填空练习(指向指针的指针)1.程序分析:2.程序源代码:main() char *s=man,woman,girl,boy,sister;char *q;int k;for(k=0;k5;k+);/*这里填写什么语句*/printf(%sn,*q);=【程序78】题目:找到年龄最大的人,并

10、输出。请找出程序中有什么问题。1.程序分析:2.程序源代码:#define N 4#include stdio.hstatic struct man char name20;int age; personN=li,18,wang,19,zhang,20,sun,22;main()struct man *q,*p;int i,m=0;p=person;for (i=0;iN;i+)if(mage)q=p+;m=q-age;printf(%s,%d,(*q).name,(*q).age);=【程序79】题目:字符串排序。1.程序分析:2.程序源代码:main()char *str120,*str2

11、20,*str320;char swap();printf(please input three stringsn);scanf(%s,str1);scanf(%s,str2);scanf(%s,str3);if(strcmp(str1,str2)0) swap(str1,str2);if(strcmp(str1,str3)0) swap(str1,str3);if(strcmp(str2,str3)0) swap(str2,str3);printf(after being sortedn);printf(%sn%sn%sn,str1,str2,str3);char swap(p1,p2)ch

12、ar *p1,*p2;char *p20;strcpy(p,p1);strcpy(p1,p2);strcpy(p2,p);=【程序80】题目:海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子?1.程序分析:2.程序源代码:main()int i,m,j,k,count;for(i=4;i10000;i+=4) count=0;m=i;for(k=0;k5;k+)j=i/4*5+1;i=j;if(j%4=0)count+;elsebreak;i=m;if(count=4)printf(%dn,count);break;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1