题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-11-29 04:45:47

[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )

int i=0;
char str [N];
char ch;
clrscr ( );
printf"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)

if (str [i]==ch)
【1】
【2】 ;

str[i]= 【3】 ;
printf"/n*** display string ***/n");
puts (str);

更多"请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符"的相关试题:

[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )

int i=0;
char str [N];
char ch;
clrscr ( );
printf"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)

if (str [i]==ch)
【1】
【2】 ;

str[i]= 【3】 ;
printf"/n*** display string ***/n");
puts (str);

[填空题]请补充main函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。
例如,输入abcdefghi*,结果显示adcdefghi。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 80
main ( )

iht i=-l, j=0;
char str IN];
clrscr ( );
printf("/n Input a string /n");
do

i++;
scanf(【1】);
while(【2】);
printf ("/n**display the string** /n");
while (j<i)

printf (【3】);
j++;


[填空题]请补充main( )函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1="computer",则str2="cmue"。 注意:部分源程序给出如下。 请勿改动函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。 试题程序: #include<stdlib.h> #include<stdio.h> #include<conio.h> #define LEN 80 void main( ) { char str1[LEN],str2[LEN]; char*p1=str1,*p2=str2; int i=0,j=0; system("CLS"); printf("Enter the string:/n"); scanf(______); printf("***the origial string***/n"); while(*(p1+j)) { printf("______",*(p1+j)); j++; } for(i=0;i<j;i+=2) *p2++=*(str1+i); *p2="/0"; printf("/nThe new string is:%s/n",______); }

[填空题]请补充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函数,该函数的功能是:从键盘输入一个字符串并保存在字符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
[填空题]请补充main函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,注意,str2的K度不大于str1,否则需要重新输入。 例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<string. h> main ( ) { char strl [ 81], str2 [ 81 ]; char *pl=strl, *p2=str2; clrscr ( ); do { printf(" Input strl tn"); gets (strl); printf(" Input str2 In"); gets (str2); }while(【1】); while(【2】) *p1++=*p2++; printf(" Display strl /n"); puts (【3】) }
[填空题]请补充函数fun( ),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。
例如:当a输入“abababa”,c=‘a’时,b的输出为“ababb”;
如果a的输入为“ababa”,则b的输出为“ababa”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
void fun(char a[],char b[],char C)

int i=0,j=0;
int n=0;
int m=0;
while(a[i]!=‘/0’)

if(a[i]==c)
n++;
i++;

【1】 ;
if(n%2)

while(a[j]!=’/0’)

b[j]=a[j];
j++;

b[j]=’/0’;

else

while(a[i]!=’/0’)

b[j++]=a[i];
if(a[i]==c)
m++;
if((m>n/2)&&(a[i]==c))
【2】
i++;

【3】

main( )

char a[LEN],b[LEN];
char c;
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main( )

int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("*** original string ***/n");
puts(str);
【1】
while(*(pf+j)).

if(*(pf+j)>=’a’&&* (pf+j)<=’z’)

*(pf+j)= 【2】
j++;

else
【3】

printf("****** new string ******/n");
puts(str);
system("pause");

[简答题]编写函数fun,其功能是:删除一个字符串中指定下标的字符。其中,a指向原字符串,删除指定字符后的字符串存放在b所指的数组中,n放指定的下标。
例如,输入一个字符串“world”,然后输入3,则调用该函数后的结果为“word”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 20
void fun(char a[],char b[],int n)


void main( )

char str1[LEN],str2[LEN];
int n;
printf("Enter the string:/n");
gets(str1);
printf("Enter the position ofthe string deleted:");
scanf("%d",&n);
fun(str1,str2,n);
printf("The new string is:%s/n",str2);

[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
  #define LEN 80
main( )

char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The 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);

我来回答:

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

订单号:

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