填空题
下列给定程序中,函数fun的功能是:将形参s所指字符串中下标为奇数的字符取出,并按ASCII码大小递增排序,将排序后的字符存入形参p所指的字符数组中,形成一个新串。
例如,形参s所指的字符串为“baawrskjghzlicda”,执行后p所指字符数组中的字符串应为“aachjlsw”。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void.fun(char*s,char*p)
{int i,j,n,x,t;
n=0;
for(i=0;s[i]!="/0";i++)n++;
for(i=1;i<n-2;i=i+2)
{
/******************found******************/
1;
/******************found******************/
for(j=
2+2;j<n;j=j+2)
if(s[t]>s[j])t=j;
if(t!=i)
{
x=s[i];
s[i]=s[t];
s[t]=x;
}
}
for(i=1,j=0;i<n;i=i+2,j++)
p[j]=s[i];
/******************found******************/
p[j]=
3;
}
main()
{char s[80]="baawrskjghzlicda",p[50];
printf("/nThe original string is:%s/n",s);
fun(s,p);
printf("/nThe result is:%s/n",p);
}