欢迎来到天天文库
浏览记录
ID:41032608
大小:60.50 KB
页数:15页
时间:2019-08-14
《c语言几个小编程》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、选择排序:#includeintmain(void){inti,index,k,n,temp;inta[10];printf(“Entern:”);scanf(%d”,&n);printf(“Enter%dintegers:”,n);for(i=0;i2、”);for(i=o;ivoidswap2(int*,int*);voidbubble(inta[],intn);intmain(void){intn,a[8];inti;printf(“Entern(n<=8):”);scanf(“%d”,&n);printf(“Entera[%d]:”,n);for(i=0;i3、=”,n);for(i=0;ia[j+1])swap2(&a[j],&a[j+1]);}voidswap2(int*px,int*py){intt;t=*px;*px=*py;*py=t;}判断字符数:#includeintmain(void){intdigit,i,letter,other;charch;digit=letter=other4、=0;printf(“Enter10characters:”);for(i=1;i<=10;i++){ch=getchar();if((ch>=’a’&&ch<=’z’)5、6、(ch>=’a’&&ch<=’z’))letter++;elseif(ch>=’0’&&ch<=’9’)digit++;elseother++;}printf(“letter=%d,digit=%d,other=%d”,letter,digit,other);return0;}手机通讯录:#include#includestructfrinds_list{ch7、arname[10];intage;chartelephone[13];};intCount=0;voidnew_friend(structfriends_listfriends[]);voidsearch_friend(structfriends_listfriends[],char*name);intmain(void){intchoice;charname[10];structfriends_listfriends[50];do{printf(“手机通讯录功能选项:1:新建2:查询0:退出”);printf(“请选择功能:”);scanf(“%d”,&choic8、e);switch(choice);case1:new_friend(friends);break;case2:printf(“请输入要查找的联系人姓名:”);scanf(“%s”,name);search_friends,name);break;case0:break;}}while(choice!=0);printf(“谢谢使用通讯录功能!”);return0;}voidnew_friend(structfriends_listfriends[]){structfriends_listf;if(Count==50){printf(“通讯录已满!”);retur9、n;}printf(“强输入新联系人的姓名:”);scanf(“%s”,f.name);printf(“请输入新联系人的年龄:”);scanf(“%d”,&f.age);printf(“请输入新联系人的联系电话:”);scanf(“%s”,f.telephone);friends[Count]=f;Count++;}voidsearch_friend(structfriends_listfriends[],char*name){inti,flag=0;if(Count==0){printf(“通讯录时空的!”);retur
2、”);for(i=o;ivoidswap2(int*,int*);voidbubble(inta[],intn);intmain(void){intn,a[8];inti;printf(“Entern(n<=8):”);scanf(“%d”,&n);printf(“Entera[%d]:”,n);for(i=0;i3、=”,n);for(i=0;ia[j+1])swap2(&a[j],&a[j+1]);}voidswap2(int*px,int*py){intt;t=*px;*px=*py;*py=t;}判断字符数:#includeintmain(void){intdigit,i,letter,other;charch;digit=letter=other4、=0;printf(“Enter10characters:”);for(i=1;i<=10;i++){ch=getchar();if((ch>=’a’&&ch<=’z’)5、6、(ch>=’a’&&ch<=’z’))letter++;elseif(ch>=’0’&&ch<=’9’)digit++;elseother++;}printf(“letter=%d,digit=%d,other=%d”,letter,digit,other);return0;}手机通讯录:#include#includestructfrinds_list{ch7、arname[10];intage;chartelephone[13];};intCount=0;voidnew_friend(structfriends_listfriends[]);voidsearch_friend(structfriends_listfriends[],char*name);intmain(void){intchoice;charname[10];structfriends_listfriends[50];do{printf(“手机通讯录功能选项:1:新建2:查询0:退出”);printf(“请选择功能:”);scanf(“%d”,&choic8、e);switch(choice);case1:new_friend(friends);break;case2:printf(“请输入要查找的联系人姓名:”);scanf(“%s”,name);search_friends,name);break;case0:break;}}while(choice!=0);printf(“谢谢使用通讯录功能!”);return0;}voidnew_friend(structfriends_listfriends[]){structfriends_listf;if(Count==50){printf(“通讯录已满!”);retur9、n;}printf(“强输入新联系人的姓名:”);scanf(“%s”,f.name);printf(“请输入新联系人的年龄:”);scanf(“%d”,&f.age);printf(“请输入新联系人的联系电话:”);scanf(“%s”,f.telephone);friends[Count]=f;Count++;}voidsearch_friend(structfriends_listfriends[],char*name){inti,flag=0;if(Count==0){printf(“通讯录时空的!”);retur
3、=”,n);for(i=0;ia[j+1])swap2(&a[j],&a[j+1]);}voidswap2(int*px,int*py){intt;t=*px;*px=*py;*py=t;}判断字符数:#includeintmain(void){intdigit,i,letter,other;charch;digit=letter=other
4、=0;printf(“Enter10characters:”);for(i=1;i<=10;i++){ch=getchar();if((ch>=’a’&&ch<=’z’)
5、
6、(ch>=’a’&&ch<=’z’))letter++;elseif(ch>=’0’&&ch<=’9’)digit++;elseother++;}printf(“letter=%d,digit=%d,other=%d”,letter,digit,other);return0;}手机通讯录:#include#includestructfrinds_list{ch
7、arname[10];intage;chartelephone[13];};intCount=0;voidnew_friend(structfriends_listfriends[]);voidsearch_friend(structfriends_listfriends[],char*name);intmain(void){intchoice;charname[10];structfriends_listfriends[50];do{printf(“手机通讯录功能选项:1:新建2:查询0:退出”);printf(“请选择功能:”);scanf(“%d”,&choic
8、e);switch(choice);case1:new_friend(friends);break;case2:printf(“请输入要查找的联系人姓名:”);scanf(“%s”,name);search_friends,name);break;case0:break;}}while(choice!=0);printf(“谢谢使用通讯录功能!”);return0;}voidnew_friend(structfriends_listfriends[]){structfriends_listf;if(Count==50){printf(“通讯录已满!”);retur
9、n;}printf(“强输入新联系人的姓名:”);scanf(“%s”,f.name);printf(“请输入新联系人的年龄:”);scanf(“%d”,&f.age);printf(“请输入新联系人的联系电话:”);scanf(“%s”,f.telephone);friends[Count]=f;Count++;}voidsearch_friend(structfriends_listfriends[],char*name){inti,flag=0;if(Count==0){printf(“通讯录时空的!”);retur
此文档下载收益归作者所有