C语言试卷
第661题
有以下程序:
#include <stdio.h>
#include <string.h>
main()
{
char a[5][10]= {"china", "beijing", "you", "tiananmen", "welcome"};
int i,j;
char t[10];
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
if(strcmp(a[i],a[j])>0)
{
strcpy(t,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],t);
}
puts(a[3]);
}程序运行后的输出结果是()。
第662题
有以下程序(strcat函数用以连接两个字符串):
#include <stdio.h>
#include <string.h>
main()
{
char a[20]="ABCD\0EFG\0", b[]="IJK";
strcat(a,b);
printf("%s\n",a);
}程序运行后的输出结果是()。
第663题
有以下程序(程序中库函数islower(ch)用以判断ch中的字符是否为小写字母):
#include <stdio.h>
#include <ctype.h>
void fun(char *p)
{
int i=0;
while(p[i])
{
if(p[i]==' '&&islower(p[i-1]))p[i-1]=p[i-1]-'a'+'A';
i++;
}
}
main()
{
char s1[100]="ab cd EFG!";
fun(s1);
printf("%s\n",s1);
}程序运行后的输出结果是( )。
第664题
有以下程序:
#include <stdio.h>
#include <string.h>
main()
{
char str[][20]={"One*World","One*Dream!"}, *p=str[1];
printf("%d,",strlen(p));
printf("%s\n",p);
}程序运行后的输出结果是()。
第665题
有以下程序
#include <stdio.h>
#include <string.h>
main()
{
char p[20]= {'a','b','c','d'}, q[]="abc", r[]="abcde";
strcat(p,r);
strcpy(p+strlen(q),q);
printf("%d\n",strlen(p));
}程序运行后的输出结果是()。
第666题
设有以下函数:
void fun(int n,char* s){……}则下面对函数指针的定义和赋值均是正确的是()。
第667题
有以下程序
#include <stdio.h>
int add(int a,int b)
{
return (a+b);
}
main()
{
int k, (*f)(),a=5,b=10;
f=add;
…
}则以下函数调用语句错误的是()。
第668题
以下叙述中正确的是()。
第669题
有以下程序
#include <stdio.h>
int fun(int n)
{
if(n==1)
return 1;
else
return(n+fun(n-1));
}
main()
{
int x;
scanf("%d",&x);
x=fun(x);
printf("%d\n",x);
}执行程序时,给变量x输入10,程序的输出结果是()。
第670题
有以下程序:
#include <stdio.h>
int fun(int n)
{
if(n)return fun(n-1)+n;
else return 0;
}
main()
{
printf("%d\n",fun(3));
}程序的运行结果是()。
第671题
有如下程序:
#include <stdio.h>
void convert(char ch)
{
if(ch<'D')convert(ch+1);
printf("%c",ch);
}
main()
{
convert('A');
printf("%\n");
}程序运行后的输出结果是()。
第672题
设有如下函数定义:
int fun(int k)
{
if(k<1) return 0;
else if(k==1) return 1;
else return fun(k-1)+1;
}若执行调用语句:n=fun(3);,则函数fun()总共被调用的次数是()。
第673题
以下程序:
#include <stdio.h>
void fun(int x)
{
if(x/2>1) fun(x/2);
printf("%d",x);
}
main()
{
fun(7);
printf("\n");
}程序运行后的结果是()。
第674题
有以下程序:
#include <stdio.h>
void fun(int n)
{
int i;
if((i=n/10)!=0)
fun(i);
putchar(n%10+'0');
}
main()
{
fun(256);
}程序运行后的输出结果是()。
第675题
有如下程序:
#include <stdio.h>
void get_put()
{
char ch;
ch=getchar();
if(ch!='\n')get_put();
putchar(ch);
}
main()
{
get_put();
printf("\n");
}程序运行时,输入1234<回车>,则输出结果是()。
第676题
有如下程序:
#include <stdio.h>
void get_put()
{
char ch;
ch=getchar();
if(ch!='\n')get_put();
putchar(ch);
}
main()
{
get_put();
}程序运行时,输入ABCD<回车>,则输出结果是()。
第677题
有以下程序:
#include <stdio.h>
void fac2(int);
void fac1(int n)
{
printf("*");
if(n>0)fac2(n-1);
}void fac2(int n)
{
printf("#");
if(n>0)fac2(--n);
}
main()
{
fac1(3);
}程序的运行结果是()。
第678题
有以下程序
#include <stdio.h>
int fun(int x)
{
int p;
if(x==0||x==1)
return (3);
p=x-fun(x-2);
return p;
}
main()
{
printf("%d\n",fun(7));
}执行后的输出结果是()。
第679题
有以下程序:
#include <stdio.h>
int f(int x)
{
int y;
if(x==0||x==1)
return (3);
y=x*x-f(x-2);
return y;
}
main()
{
int z;
z=f(3);
printf("%d\n",z);
}程序的运行结果是()。
第680题
有以下程序:
#include <stdio.h>
int f(int t[],int n);
main()
{
int a[4]={1,2,3,4},s;
s=f(a,4);
printf("%d\n",s);
}
int f(int t[],int n)
{
if(n>0)return t[n-1]+f(t,n-1);
else return 0;
}程序运行后的输出结果是()。