A.acknowledged
B.admitted
C.admired
D.acquainted
第1题
请补充函数proc(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码升序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传人。
例如,如果输入“9fedcba”,则输出为“abcdefg”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
第2题
请补充fun()函数,该函数的功能是:把字符的ASCII码中为奇数的字符从字符串str中删除,结果仍然保存在字符串str中,字符串str从键盘输人,其长度作为参数传人fun()函数。
例如,输入“abcdef”,则输出“bdf”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在mare()函数的横线上填入所编写的若干表达式或语句。
试题程序:
第3题
请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“ace”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
inc lude< stdio, h>
define N 80
【 】
{
int i, j;
【 】
for (i=0;i<n;i++)
{
if (s [i] %2!=0)
s [j++]=s [i];
}
【 】;
}
main ()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf ("\nInput a string:\n");
gets (str);
while (str [i] !=' \0' )
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
第4题
请补充函数fun(),该函数的功能是:把字符下标能铍2或3整除的字符从字符串str中删除,把剩余的字符重新保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijk”,输出“bfh”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[], int n)
{
int i, k;
【 】;
for(i=0; i<n; i++)
{
s[k++]=s[i];
if(【 】)
k--;
}
【 】;
}
main()
{
int i=0,strlen=0;
char str[N];
clrscr();
printf("\nInput a string:\n");
gets(str);
while(str[i]!='\0')
{
strlen++;
i++;
}
fun(str,strlen);
printf('\n*** display string ***\n");
puts(str);
}
第5题
请补充函数fun(),该函数的功能是:把字符下标能铍2或3整除的字符从字符串str中删除,把剩余的字符重新保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijk”,输出“bfh”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[], int n)
{
int i, k;
【 】;
for(i=0; i<n; i++)
{
s[k++]=s[i];
if(【 】)
k--;
}
【 】;
}
main()
{
int i=0,strlen=0;
char str[N];
clrscr();
printf("\nInput a string:\n");
gets(str);
while(str[i]!='\0')
{
strlen++;
i++;
}
fun(str,strlen);
printf('\n*** display string ***\n");
puts(str);
}
第6题
请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“bdf”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j;
j=0;
for(i=0;【 】;i++)
{
if(【 】)
s [j++]-s [i];
}
【 】;
}
main ()
{
int i=0, strlen=0;
char str [N];
clrscr ();
printf ("\nInput a string: \n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun(str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
第7题
编写函数fun(),该函数的功能是从字符串中删除指定的字符,同一字母的大、小写按不同字符处理。
例如:程序执行时输入字符串为turbo c and borland c++,从键盘上输入字符n,则输出后变为turbo c ad borlad c++。
如果输入的字符在字符串中不存在,则字符串照原样输出。
注意:部分源程序已存在文件test18_2.cpp中。
请勿改动主函数脚in和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test18_2.cpp的内容如下:
include<stdio.h>
include<iostream.h>
include<conio.h>
void fun(char s[ ], int c)
{
}
void main ()
{
static char str[ ]="turbo c and borland c++";
char ch;
cout<<"原始字符串:\n"<<str<<end1;
cout<<"输入一个字符:";
cin>>ch;
fun(str.ch);
cout<<"str="<<str<<end1;
}
第8题
请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijkl”,输出“cdfhl”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j, k, flag;
【 】;
for(i=0; i<n; i++)
{
if (i>1)
s [k++] =s [i];
flag=I;
for(【 】; j<i&&flag; j++)
if (i%j==0)
{
flag=0;
【 】
}
}
s [k]='\0';
}
main()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf("\n Input a string:\n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
第9题
请补充main()函数,该函数的功能是:把一个二维字符
数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]={″hoih″,″yufui″,″xgf″),则str=″oyx″。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填人所编写的若干表达式或语句。
试题程序:
第10题
请补充函数fun(),该函数的功能是;删除字符数组中小于等于指定字符的字符,指定字符从键盘输入,结果仍保存
例如,输入“abcdefghij”,指定字符为‘d’,则结果输出“defghij”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio. h>
define N 80
void fun (char s[], char ch)
{
int i=0, j=0;
while (s [i] )
{
if (s Iii<ch)
【 】;
else
{
【 】
i++;
}
}
【 】
}
main ()
{
char str [N], ch;
clrscr ();
printf("\n Input a string:\n");
gets (str);
printf("\n*** original string ***\n");
puts (str);
printf("\n Input a character:\n");
scanf ("%c", &ch);
fun(str, ch);
printf("\n*** new string ***\n");
puts (str);
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!