更多"请补充函数fun( ),该函数的功能是:把ASCⅡ码为偶数的字符从字符"的相关试题:
[填空题]请补充函数fun( ),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun( )。
例如,输入“abcdef”,输出“ace”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#inc lude< stdio, h>
#define N 80
【1】
int i, j;
【2】
for (i=0;i<n;i++)
if (s [i] %2!=0)
s [j++]=s [i];
【3】 ;
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);
[简答题]填空题
请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。
例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define N 40
void fun(char *str1,char *str2)
{
int i=0,j=0,k=0,n;
char ch;
char *p1=str1;
char *p2=str2;
while(*(p1+i))
i++;
while(*(p2+j))
j++;
n=【1】;
for(;k<=j/2;k++,j--)
{
ch=*(p2+k);
*(p2+k)=*(p2+j);
*(p2+j)=ch;
}
【2】;
for(;【3】;i++)
*(p1+i)=*p2++;
*(p1+i)=’’/0’’;
}
main( )
{
char str1[N],str2[N];
int m,n,k;
clrscr( );
printf("***Input the string str1 & str2
***/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("*** The string str1 & str2 ***/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*** The new string ***/n");
puts(str1);
}
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[填空题]请补充函数fun( ),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“cdefgh”,则输出为“hgfedc”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun (char s [], int n)
int i, j;
char ch;
for (i=0; i<n; i++)
for(j= 【1】 ;j<n;j++)
if (s[i]<s [j])
ch=s [j];
【2】 ;
s [i] =ch;
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);
[填空题]请补充fun( )函数,该函数的功能是求m的阶乘。不要改动主函数main( )与他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式或语句。
注意:部分源程序如下。
#include<stdio.h>
long fun(int m)
if (1)
return(m*fun (2) );
return (3) ;
main( )
printf("8!=%ld/n",fun(8));
[单项选择]若有函数fun(x,y),并且已经使函数指针变量p指向函数fun,则使用p调用函数fun的正确方法是( )。
A. (*p) fun(x,y);
B. *pfun(x,y);
C. (*p)(x,y)
D. *p(x,y)
[简答题]请编写函数fun( ),该函数的功能是判断字符串是否为回文,若是则函数返回1,主函数中输出YES:否则返回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。
例如:字符串LEVEL是回文,而字符串123312就不是回文。
注意;部分源程序已存在文件test26_.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test26_2.cpp的内容如下:
#include<iostream.h>
#include<stdio.h>
#define N 80
int fun(char*str)
void main( )
char s[N];
cout<<"Enter a string:"<<endl;
getss);
cout<<"/n/n";
puts(s);
if(fun(s))
cout<<"YES/n";
else
cout<<"NO/n";
[简答题]简单应用题 请编写函数fun( ),该函数的功能是判断字符串是否为回文,若是则函数返回1,主函数中输出YES;否则返回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。 例如:字符串LEVEL是回文,而字符串123312就不是回文。 注意:部分源程序已存在文件kt11_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件kt11_2.cpp的内容如下: #include #include #defineN80 intfun(char*str) { } voidmain( ) { chars[N]; cout<<"Enterastring:"<
[填空题]若有函数fun(x,y),并且已经使函数指针变量p指向函数fun,则使用p调用函数fun的方法是______。
[填空题]请补充fun函数,fun函数的功能是求n的阶乘。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句
试题程序:
#include<stdio.h>
long fun(int n)
if( (1) )
return(n*fun( (2) ));
return (3) ;
main( )
printf("10!=%1d/n",fun(10));