首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列给定程序中,函数proc()的功能是:首先把b所指字符串中的字符按逆序存放,然后将str1所指字符串中的字符和str2所指字符串中的字符,按排列的顺序交叉合并到str所指数组中,过长的剩余字符接在str所指数组的尾部。例如,当str1所指字符串中的内容
下列给定程序中,函数proc()的功能是:首先把b所指字符串中的字符按逆序存放,然后将str1所指字符串中的字符和str2所指字符串中的字符,按排列的顺序交叉合并到str所指数组中,过长的剩余字符接在str所指数组的尾部。例如,当str1所指字符串中的内容
admin
2013-03-25
28
问题
下列给定程序中,函数proc()的功能是:首先把b所指字符串中的字符按逆序存放,然后将str1所指字符串中的字符和str2所指字符串中的字符,按排列的顺序交叉合并到str所指数组中,过长的剩余字符接在str所指数组的尾部。例如,当str1所指字符串中的内容为ABCDEFG,str2所指字符串中的内容为1234时,str所指数组中的内容应该为A483C2DIEFG;而当str1所指字符串中的内容为1234,str2所指字符串中的内容为ABCEDFG时,str所指数组中的内容应该为1G2F3E4DCBA。
请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
#include
#include
void proc(char*str1,char*str2,char * str)
{
int i,j;char ch;
i=0;j=strlen(str2)-1;
//****found****
while(i>j)
{
ch=str2
;str2
=str2[j];str2[j]=ch;
i++;j--;
}
while(*str1||*str2)
{
if(*str1){*str=*str1;str++;str1++;)
if(*str2){*str=*str2;str++;str2++;)
}
//****found****
*str=0;
}
void main()
{
char s1[100],s2[100],t[200];
system("CLS");
printf("\nEnter s1 string:");
scaIif("%s",s1);
printf("\nEnter s2 string:");
scanf("%s",s2);
proc(s1,s2,t);
printf("\nThe resuh is:%s\n",t);
}
选项
答案
(1)错误:while(i>j) 正确:while(i
解析
由函数proc()可知,变量i和j分别存放的是字符串str前面和后面第i个字符的位置,当i
j)”应改为“while(i
转载请注明原文地址:https://jikaoti.com/ti/fKn0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下数组定义中不正确的,是______。
若有说明inti,j=2,*p=&i;则能完成i=j赋值功能的语句是______。
以下程序的输出结果是______。#include<stdio.h>main(){inta=200;#definea100printf("%d",a);#undefapri
以下函数用来在w数组中插入x。n所指向的存储单元中存放w数组中字符个数。数组w中的字符已按从小到大的顺序排列,插入后数组w中的字符仍有序。请填空。voidfun(char*w,charx,int*n){inti,
在位运算中,操作数左移一位,其结果相当于
以下程序段的执行结果为#definePLUS(X,Y)X+Ymain(){intx=1,y=2,z=3,sum;sum=PLUS(x+y,z)*PLUS(y,z);printf("SUM=%d",sum
下面函数调用语句含有实参的个数为func((exp1,exp2),(exp3,exp4,exp5));
数据存储和数据流都是______,仅仅是所处的状态不同。
长度为n的顺序存储线性表中,当在任何位置上插入一个元素概率都相等时,插入一个元素所需移动元素的平均个数为【】。
随机试题
试论泰罗管理理论的要点。
当事人提出证据证明仲裁裁决有下列情形之一,可向人民法院申请撤销仲裁裁决
实质性病变的声像图中,哪项错误
聚氧乙烯脱水出梨醇单油酸酯的商品名称是
临床一期梅毒症状,多于不洁性交后出现,其时间是()
夏柯三联征是指
下列关于刑事案件法院之间司法协助叙述正确的是:()
研究货币需求量必须解决的基本问题有()。
某公交公司因未按规定在公交车上配安保人员和安保设施,被公安机关予以警告,责令改正,一个月后该公交公司仍拒不改正,公安机关对其处以5万元罚款。处罚依据是:
下列对有关法律的解释,正确的是()。
最新回复
(
0
)