- 1、本文档共36页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
程序cmody032.c的功能是:输出201~300之间的所有素数,统计总个数 #include stdio.h #include math.h void main( ) { int num; printf(“\n”); num=fun( ); printf(“\n The total of prime is %d”, num); getch( ); } int fun() { int m, i, k, n=0; for(m=201; m=300; m+=2) * 1.程序cmody011.c的功能是:从字符数组str1中取出ASCII码为偶数且下标为偶数的字符依次存放到字符串t中。 例如, 若str1所指的字符串为:4AZ18c?Ge9a0z! 则t所指的字符串为:4Z8z 注意:数组下标从0开始。 #include math.h #include stdio.h #include string.h #include conio.h void main( ) { char str1[100], t[100]; int i, j; /**/i=0; /**/ clrscr( ); strcpy(str1, “4AZ18c?Ge9a0z!”); for(i=0; istrlen(str1); i++) { /**/if ((str1[i]%2= =0)(i%2!=0))/**/ { t[j]=str[i]; j++; } t[j]=’\0’; printf(“\n Original string:%s\n”, str1); printf(“\n Result string: %s\n”, t); } i=0; j=0; if((str[i]%2= =0)(i%2==0)) 程序cmody041.c,其功能是统计输入字符串中小写英文字母的个数 如 输入:abcdEFGHIJK123 输出:4 #include stdio.h #include string.h void main( ) { char str1[128]; /**/ int i; len, sum=0; /**/ gets(str1); len=strlen(str1); for(i=0; ilen; i++) { /**/if(str[i]=’a’|| str1[i]=’z’) /**/ sum++; } printf(“%d\n”, sum); getch( ); } int i, len, sum=0; if(str[i]=‘a’str[i]=‘z’) 程序cmody051.c,其功能是统计输入字符串中大写英文字母的个数 如 输入:abcDEFGH123 输出:5 #include stdio.h #include string.h void main( ) { /**/char str1; /**/ int i, len, sum=0; gets(str1); len=strlen(str1); for(i=0; ilen; i++) { if(str[i]=’A’str1[i]=’Z’) /**/sum- -; /**/ } printf(“%d\n”, sum); getch( ); } char str1[80]; sum++; 5. 程序 cmody 041.c其功能是统计输入字符串阿拉伯数字的个数如输入:abcdEFG456IJK123 输出:6 #include stdio.h #include string.h void main( ) { char str[120]; /**/ int i, len; sum=0; /**/ printf(“\n please input the string:”); gets(str1); len=strlen(str1); for(i=0; ilen; i++) { /**/ if(str1[i]=’0’||str1[i]=’9’) /**/ sum++; } printf(“%d\n”, sum); getch( ); } int i, len, sum=0; if(str1[i]=‘0’str[i]=‘9’) 6. 程序cmody051.c的功能是:从键盘输入一个字符串,分别统计其中的英文字母、阿拉伯数字和其他字符的个数。例如: 输入:Beijing-2008 输出:letter=7, number=4, other=1 #include stdio.h #include conio.h void main( ) { cha
文档评论(0)