正在加载图片...
3 1360 4 4-8从键盘上输入一个字符,用折半查找法找出该字符在已排序的字符串a中 的位置。若该字符不在a中,则打印“该字符不在a中”。试完善程序S4-8C。 源程序S4-8C include <stdio.h> maino i char a[12]="abcdefklmnp" ch int 1, top, bot, mid printf("Input a character In") scanf("%", &ch printf("ch=%cIn",ch); if(bot>top) printf(("该字符不在a中Ⅶn"), 4-9不用 strcat)函数,将两个字符串连接起来,试完善程序S49C。 程序S49.C maino i char sl[80], S2[40] int F=,=0; printf("Enter s1: ) scanf("%s", s1) printf("Enter s2: ) scanf("%s", S2) printf("rEsult is: %s"S1) getcho 4-10程序S4-10.C的功能是找出数组x中的最小值和次小值,并分别将其与x[O] 和x[交换。调试程序,使其能够运行出正确的结果。 注意:不能增加行或删除行,也不能更改程序的结构, 源程序S4-10C1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 ┇ ┇ 4-8 从键盘上输入一个字符,用折半查找法找出该字符在已排序的字符串 a 中 的位置。若该字符不在 a 中,则打印“该字符不在 a 中”。试完善程序 S4-8.C。 源程序 S4-8.C # include <stdio.h> main() { char a[12]="abcdefklmnp",ch; int i, top,bot,mid; printf("Input a character \n"); scanf("%c",&ch); printf("ch=%c\n",ch); if (bot >top) printf("该字符不在 a 中\n"); } 4-9 不用 strcat()函数,将两个字符串连接起来,试完善程序 S4-9.C。 源程序 S4-9.C main() { char s1[80],s2[40]; int i=0,j=0; printf("Enter s1:"); scanf("%s",s1); printf("Enter s2:"); scanf("%s",s2); printf("\nResult is:%s",s1); getch(); } 4-10 程序S4-10.C的功能是找出数组x中的最小值和次小值,并分别将其与x[0] 和 x[1]交换。调试程序,使其能够运行出正确的结果。 注意:不能增加行或删除行,也不能更改程序的结构, 源程序 S4-10.C
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有