下列给定程序中,函数flm的功能是:将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持
例如,s所指的字符串为“def35adh3kjsdt7”,执行后结果为“defadhajsdt3537”。
请在程序的下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。注意:部分源程序在文件BLANKl.c中。
不得增行或删行,也不得更改程序的结构!
例如,s所指的字符串为“def35adh3kjsdt7”,执行后结果为“defadhajsdt3537”。
请在程序的下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。注意:部分源程序在文件BLANKl.c中。
不得增行或删行,也不得更改程序的结构!
第1题
下列给定程序中函数proc()的功能是:将长整型数中为偶数的数依次逆向取出,构成一个新数放在t中。高位在低位,低位在高位。例如,当s中的数为12345678时,则t中的数为8642。
请修改函数proc()中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
第2题
下列给定程序中,函数fun()的功能是;将s所指字符串中的字母转换为按字母序列的后续字母(但Z转化为A,z转化为 a),其他字符不变。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <ctype.h>
include <conio.h>
void fun(char *s)
/*************found**************/
{ while(*s!='@')
{ if(*s>='A' &*s<='z'||*s>='a'&&*s<='z')
{if(*s=='Z') *S='A';
else if(*S=='z') *s='a';
else *s+=1;
}
/*************found**************/
(*s)++;
}
}
main()
{ char s[80];
clrscr();
printf("\n Enter a string with length <80:\n\n");gets(s);
printf("\n The string:\n\n");puts(s);
fun(s);
printf("\n\n The Cords:\n\n");puts(s);
}
第3题
下列给定程序中函数fun()的功能是:将长整型数中每一位上为奇数的数依次取出,构成一个新数放在冲。高位仍在高位,低位仍在低位。例如当s中的数为87653142时,t中的数为7531。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conlo.h>
void fun (long s, long *t)
{int d;
long s1=1;
/*************found**************/
t=0;
while(s>0)
{ d=s%10;
/*************found**************/
if(d%2==0)
{*t=d*s1+*t;
s1*=10;
}
s/=10;
}
}
main()
{long s, t;
clrscr();
printf("\nPlease enter s:");scanf("%ld",&s);
fun(s,&t);
printf("The result is:%ld\n",t);
}
第4题
下列给定程序中,函数6m的功能是:将形参S所指字符串中下标为奇数的字符取出。并按ASCIl码大
小递增排序,将排序后的字符存入形参P所指的字符数组中,形成一个新串。
例如。形参8所指的字符串为“baawrskjghzlicda”,执行后P所指字符数组中的字符串应为“aachjl。w”。
请在下划线处填入正确的内容并将下划线删除。使程序得出正确的结果。
注意:部分源程序给出如下。 ’
不得增行或删行,也不得更改程序的结构!
试题程序:
第5题
下列给定程序中,函数fun()的功能是将字符串s中位于偶数位置的字符或ASCII码为奇数的字符放入字符串t中(规定第一个字符放在第0位中)。
例如:字符串中的数据为ADFESHDI,则输出应当是 AFESDI。
请改正程序中的错误,使它能得到正确结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
define N 80
/************found*************/
void fun(char s,char t[])
{
int i,j=0;
for(i=0;i<strlen(s);i++)
/*********found*+************/
if(i%2=0 || s[i]%2!=0)
t[j++]=s[i];
t[j]='\0';
}
main()
{
char s[N],t[N];
clrscr();
printf("\nPlease enter string s:");
gets(s);
fun(s,t);
printf("\nThe result is:%s\n",t);
}
第6题
下列给定程序中函数fun()的功能是:将长整型数中每一位上为偶数的数依次逆向取出,构成一个新数放在t中。高位在低位,低位在高位。例如当s中的数为25846513时,t中的数为6482。 请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conio.h>
void fun(long S,long *t)
{
int d;
long sl=l,i=1;
*t=0;
while(s/i>0)
i=i*10;
i=i/10;
while(s>0)
{
d=s/i
/*************found*************/
if(d%2!=0)
{
/*************found*************/
t=d*sl+t;
sl*=l0;
}
S=S%i;
i=i/10;
}
}
main()
{
long S,t;
clrscr();
printf("\nPlease enter S:");
scanf("%ld",&s);
fun(S,&t);
printf("The result is:%ld\n",t);
}
第7题
下列给定程序中,函数fun()的功能是:将长整型数中每一位上为偶数的数依次取出,构成一个新数放在冲。高位仍在高位,低位仍在低位。例如,当s中的数为87653142时,t中的数为8642。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main,~数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <stdio.h>
void fun(long s,long *t)
/**********************************/
{ int d;
long s1=l;
*t=0;
while(s>0)
{ d=s%10;
/**********************************/
if(d%2=0)
{*t=d*sl+*t;
sl*=10
}
/**********************************/
s\=10;
}
}
main ()
{ long s,t;
clrscr();
printf("\nPlease enter s: "); scanf
("%ld",&s);
fun(s,&t);
printf("The result is :%ld\n",t);
}
第8题
给定程序MODll.C中函数fun的功能是:将s所指字符串中的字母转换为按字母序列的后续字母(但z转换为A,z转换为a),其他字符不变。
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
第9题
下列给定程序中,函数fun()的功能是:将m(1≤m≤10)个字符串连接起来,组成一个新串,放入pt所指字符串中,例如:把3个串abc,CD,EF串联起来,结果是abcCDEF。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <string.h>
include <stdio.h>
/*************found**************/
int fun(char str[] [10],int m, char *pt)
{ int k,q,i,j=0;
for(k=0;k<m;k++)
{ q=strlen(str[k]);
j+=q;
for(i=0;i<q;i++)
/*************found**************/
pt[i]=str[k,i];
pt+=q;
pt[0] =0;
}
pt-=j;
}
main ()
{ int m, h;
char s[10] [10],p[120];
clrscr ();
printf("\nPlease enter m: ");
scanf("%d",&m); gets(s[0]);
printf ("\nPlease enter %d string:In ",m);
for(h=0;h<m;h++) gets(s[h]);
fun (s,m,p);
printf("\nThe result is :%s\n ",p);
}
第10题
下列给定的程序中,fun()函数的功能是:将p所指字符串中每个单词的最后一个字母改成大写(这里的“单词”是指有空格隔开的字符串)。例如,若输入:
I am a student to take the examination
则应输出:I aM A studenT tO take thE examinatioN
请改正程序中的错误,使它能得出正确的结果。
注童:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <ctype.h>
include <stdio.h>
void fun(char *p)
{
int k=0;
for (; *p;p++)
if (k)
{
/*************found**************/
if (p=='')
{
k=0;
/*************found**************/
*p=toupper(*(p-1));
}
}
else
k=1;
}
main()
{char chrstr[64];
int d;
clrscr();
printf("\nPlease enter an English sentence within 63 letters:");
gets(chrstr);
d=strlen(chrstr);
chrstr[d==' ';
chrstr[d+1]=0;
printf("\nBofore changing:\n %s",chrstr);
fun(chrstr);
printf("\nAfter changing:\n%s",chrstr);
}
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!