题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-05 18:41:59

[填空题]请补充main函数,该函数的功能是:把字符串str中的字符向前移动一位,原来的第一个字符移动到字符串尾,结果仍然保存在原字符串中。 例如,输入“how do you do”,则结果输出“ow do you doh”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio. h> #define N 80 main( ) { char str[N], ch; int i; clrscr ( ); printf("/n Input a string:In"); gets (str); printf("/n*** original string ***In"); puts (str); ch=str [0]; for (i=0; 【1】 ; i++) str [i]=str [i+1]; 【2】 ; printf("/n *** new string ***/n"); puts (str); }

更多"请补充main函数,该函数的功能是:把字符串str中的字符向前移动一位"的相关试题:

[填空题]请补充main函数,该函数的功能是:把字符串str1中的非空格字符拷贝到字符串str2中。 例如,若sffl=“glad to see you!”, 则str2=“gladtoseeyou!”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #define N 80 main( ) { static char strl [N] ="glad to see you!"; char str2 IN]; int i=0, j=0; clrscr ( ); printf("/n***** strl*****/n "); puts (str1); while (str1 [i] ) { if(【1】) str2 [J++] =strl [i]; 【2】; } printf("/n***** str2 *****/n "); for (i=0; i<j; i++) printf ("%c", str2 [i] ); }
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#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<j;i+=2)
*p2++=*(str1+i);
*p2=’/0’;
printf("/nThe new string is:%s/n", 【3】 );

[填空题]请补充main函数,该函数的功能是:把字符串str中的字符向前移动一位,原来的第一个字符移动到字符串尾,结果仍然保存在原字符串中。
例如,输入“how do you do”,则结果输出“ow do you doh”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main( )

char str[N], ch;
int i;
clrscr ( );
printf("/n Input a string:In");
gets (str);
printf("/n*** original string ***In");
puts (str);
ch=str [0];
for (i=0; 【1】 ; i++)
str [i]=str [i+1];
【2】 ;
printf("/n *** new string ***/n");
puts (str);

[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)

int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】
*(p1+i)=’/0’;
main( )

char str1[N],str2[N);
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);

[填空题]请补充fun函数,该函数的功能是:把字符的ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串中,字符串str从键盘输入,其长度作为参数传入fun函数。
例如,输入“abcdef”则输出“bdf”。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 100
void (1)

int i,j;
(2)
for(i=0;i<n;i++)
char str[N];
printf("please input a string:/n");
gets(str);
while(str[i]!=’/0’)

len++;
if(s[i]%2==0)
s[j++]=s[i];
(3)

main( )

int i=0,len=0;
i++;

fun(str,len);
printf("The result string:/n");
puts(str);


[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。 例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #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,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。 例如: 当str1=“cdef",str2=“cde”时,函数fun( )返回“>”。 注意:部分源程序给出如下。 请勿改动主函数main 和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: # include< stdio, h> #include<conio. h> #define N 80 char *fun (char *str1,char *str2) { char *p1=str1, *p2=str2; while (*p1 & & *p2 ) { if ( 【1】 ) return "<"; if( 【2】 ) return ">"; p1++; p2++; } if (*p1=*p2) return "=="; if (*p1== 【3】 ) return "<"; else return ">"; } main( ) { char str1 [N], str2 [N]; clrscr ( ); printf ("Input str1: /n"); gets (str1); printf ("Input str2: /n"); gets (str2); printf ("/n*****the result*****/n"); printf ("/nstr1 %s str2", fun (str1, str2) ); }
[简答题]填空题 请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include #include main( ) { int i,b[11]; char *str="ab123456789cde090"; char *p=str; clrscr( ); printf("*** the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) { switch(【1】) { case ’’0’’:b[0]++;break; case ’’1’’:b[1]++;break; case ’’2’’:b[2]++;break; case ’’3’’:b[3]++;break; case ’’4’’:b[4]++;break; case ’’5’’:b[5]++;break; case ’’6’’:b[6]++;break; case ’’7’’:b[7]++;break; case ’’8’’:b[8]++;break; case ’’9’’:b[9]++;break; 【2】 } 【3】 } printf("****** the result ********/n"); for(i=0;i<10;i++) printf("/n%d:%d",i,b[i]); printf("/nother charactor:%d",b[i]); }
[填空题]请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。
例如: 当str1=“cdef",str2=“cde”时,函数fun( )返回“>”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
# include< stdio, h>
#include<conio. h>
#define N 80
char *fun (char *str1,char *str2)

char *p1=str1, *p2=str2;
while (*p1 & & *p2 )

if ( 【1】 )
return "<";
if( 【2】 )
return ">";
p1++;
p2++;

if (*p1=*p2)
return "==";
if (*p1== 【3】 )
return "<";
else
return ">";

main( )

char str1 [N], str2 [N];
clrscr ( );
printf ("Input str1: /n");
gets (str1);
printf ("Input str2: /n");
gets (str2);
printf ("/n*****the result*****/n");
printf ("/nstr1 %s str2", fun (str1, str2) );

[填空题]请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #include <conio.h> main( ) { int i,b[11]; char *str="abl23456789cde090"; char *p=str; clrscr( ); printf("***the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) { switch( 【1】 ) { case ’0’:b[0]++;break; case ’1’:b[1]++;break; case ’2’:b[2]++;break; case ’3’:b[3]++;break; case ’4’:b[4]++;break; case ’5’:b[5]++;break; case ’6’:b[6]++;break; case ’7’:b[7]++;break; case ’8’:b[8]++;break; case ’9’:b[9]++;break; 【2】 } 【3】 } printf("****** the result ********/n");

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码