A.hoell
B.hello
C.oellh
D.olleh
第1题
#include <stdio.h>
#include <string.h>
void fun ( char *str )
{ char temp;int n,i;
n=strlen ( str ) ;
temp=str[n-1];
for ( i=n-1;i>0;i-- ) str[i]=str[i-1];
str[0]=temp;
}
main ()
{ char s[50];
scanf ( " %s " ,s ) ; fun ( s ) ; printf ( " %s\n " ,s ) ;}
程序运行后输入: abcdef< 回车 > ,则输出结果是 【 12 】 。
第2题
#include <stdio.h>
#include <string.h>
void fun ( char *str )
{ char temp;int n,i;
n=strlen ( str ) ;
temp=str[n-1];
for ( i=n-1;i>0;i-- ) str[i]=str[i-1];
str[0]=temp;
}
main ()
{ char s[50];
scanf ( " %s " ,s ) ; fun ( s ) ; printf ( " %s\n " ,s ) ;}
程序运行后输入: abcdef< 回车 > ,则输出结果是 【 12 】 。
第3题
include <stdio.h>
include <string.h>
char *fun(char *0
{ char *p--t;
return (p+strlen(t)/2);
}
main()
{ char *str="abcdefgh";
str=ftm(str);
puts(str);
}
第4题
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或者删行,也不得改变程序的结构!
试题程序:
include <conio.h>
include <string.h>
include <stdio.h>
void fun(char str[][10],int m,char *pt)
{
int k,q,i,j=0;
/*************found*************/
for(k=m;k>0;k--)
{
q=strlen(str[k]);
j+=q;
for(i=0;i<q;i++)
pt[i]=str[k][i];
pt+=q;
pt[0]=0;
}
/*************found**************/
pt=j;
}
main()
{int m,h;
char s[10][10],p[120];
clrscr();
printf("\nPlease enter m:");
scanf("%d",& m);
printf("\nPlease enter%d string:\n",m);
gets(s[0]);
for(h=0;h<m;h++)
gets(s[h]);
fun(S,m,p);
printf("/nThe result iS:%s\n",p);
}
第5题
A、gao
B、string
C、str
D、结果不确定
第6题
例如,输入一个字符串world,然后输入3,则调用该函数后的结果为word。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include <conio.h>
define LEN 20
void fun (char a[], char b [], int n)
{
}
main ()
{
char str1 [LEN], str2 [LEN];
int n ;
clrscr ();
printf ("Enter the string : \n") ;
gets (str1) ;
printf ("Enter the position of the string
deleted: ");
scanf ("%d", &n) ;
fun (str1, str2, n) ;
printf ("The new string is : %s \n",
str2) ;
}
第7题
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <string.h>
include <stdio.h>
/*************found**************/
int fun(char str[] [10],int m, char *pt)
{ int k,q,i,j=0;
for(k=0;k<m;k++)
{ q=strlen(str[k]);
j+=q;
for(i=0;i<q;i++)
/*************found**************/
pt[i]=str[k,i];
pt+=q;
pt[0] =0;
}
pt-=j;
}
main ( )
{ int m, h;
char s[10] [10],p[120];
clrscr ();
printf("\nPlease enter m: ");
scanf("%d",&m); gets(s[0]);
printf ("\nPlease enter %d string:In ",m);
for(h=0;h<m;h++) gets(s[h]);
fun (s,m,p);
printf("\nThe result is :%s\n ",p);
}
第8题
例如: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 *pl=str1;
char*p2=str2;
while(【 】)
i++;
for(;【 】;i++)
*(p1+i)=【 】;
*(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);
}
第9题
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<stdlib.h>
include<string.h>
int fun(char *str)
{
int n;
char *p=str;
【 】;
p++;
while (*p)
{
n=【 】;
p++;
}
return【 】;
}
main()
{
char str[9];
int i;
int n;
printf ("Enter a string made up of '0' and
'1' digital character:");
gets (str);
if (strlen(str)>8)
{
printf ("Error:string too longer!
please input again !\n\n");
exit(0);
}
for(i=0;str[i];i++)
if(str[i]<'0'||str[i]>'1')
{
printf("Error:%c not is '0'and
'1' digital character !\n\n",
str[i]);
exit(0);
}
printf("The original string:");
puts(str);
n=fun(str);
printf("\n%s is convered to decimal
number:%d\n\n",str,n);
}
第10题
A.asdafaaz67
B.asdafaaz67
C.asd
D.z67
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!