更多"下列函数从字符数组s[]中删除和c一样的字符,请在下面横线处填空。
"的相关试题:
[填空题]下列函数从字符数组s[]中删除和c一样的字符,请在下面横线处填空。
void delete(s,c)
char s[],c;
int i,j;
for(i=j=0;______;i++)
if(s[i]!=’c’)
s[j++]=s[i];
s[j]="/0";
[简答题]自定义一个函数,函数的形参为字符数组s1和s2,函数功能是将字符串s1中的所有数字字符取出,存入另一字符数组s2中,使s2成为一个新的字符串,并在函数中将字符串s2输出。
[填空题]从键盘输入一组小写字母,保存在字符数组str中。请补充函数fun( ),该函数的功能是:把字符数组str中字符下标为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。
例如,输入“acegikm”,输出“aCeGiKm”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun (char s[])
int i=0;
while ( 【1】 )
if (i%2!=0)
s[i]-= 【2】 ;
【3】 ;
main ( )
char str [N];
clrscr ( );
printf("/n Input a string:/n");
gets (str);
printf("/n*** original string ***/n");
puts (str);
fun (str);
printf ("In*** new string ***/n");
puts (str);
[填空题]请补充main函数,改函数的功能是,把一个二维字符数组每行字符串最大的字符拷贝到字符数组s中。
例如,如果str[3]={"efjh","cfimls","owys"},则s;"hsy"。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#inc lude<stdio, h>
main( )
{
int i=0;
char *str [3] ={ "efjh", "efknls",
"owys" };
char **p;
char s [8];
clrscr 0;
【1】;
for (i=O; i<3; i++)
{
s [i] =*p [i];
while (*p [i] )
{
if (S [i] <*p [i] )
s [i] =*p[i];
【2】;
}
}
【3】;
printf(" new string /n");
puts (s);
}
[填空题]请补充main函数,改函数的功能是,把一个二维字符数组每行字符串最大的字符拷贝到字符数组s中。
例如,如果str[3]="efjh","cfimls","owys",则s;"hsy"。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#inc lude<stdio, h>
main( )
int i=0;
char *str [3] = "efjh", "efknls",
"owys" ;
char **p;
char s [8];
clrscr 0;
【1】;
for (i=O; i<3; i++)
s [i] =*p [i];
while (*p [i] )
if (S [i] <*p [i] )
s [i] =*p[i];
【2】;
【3】;
printf(" new string /n");
puts (s);
[填空题]函数delete(s,i,n)的作用是从字符串s中删除从第i个字符开始的n个字符,请填空。
void delete(char s[],int i,int n)
int j,k,length=0;
while(s[length])
;
-i;
j=i;
If( )
k=i+n;
if(i+n<=length)
while(k<length)
s[j++]=s[k++];
s[j]=’//0’;
[填空题]请补充main( )函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i=0;
char *arr[3]="hoih", "yufui", "xgf";
char **p;
char str[8];
system("CLS");
(1) ;
for(i=0; i<3; i++)
str[i]= *p[i];
while(* p[i])
if (str[i]<*p[i])
str[i]=*p[i];
(2) ;
(3) ;
printf("new string/n");
puts(str);
[填空题]在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度 (不得使用系统提供的字符串处理函数)。
int GJetLen(char*str)
{
if( 【8】 ) return 0;
else return 1+GetLen (str+1);
}