printf("%d%d%d\n",a,b,c);
}
(9)以下程序运行后的输出结果是10 20 0
main()
{
int a,b,c
a=10;b=20;c=(a%b<1)||(a/b>1);
printf("%d%d%d\n",a,b,c);
}
(10)以下程序运行后的输出结果是0918273645
main()
{
charc1,c2;
for(c1='0',c2='9';c1 printf("%c%c",c1,c2);
printf("\n");
}
(11)已知字符A的ASCII代码值为65,以下程序运行时若从键盘输入:
B33<回车>.输出结果是 1B
#include"stdio.h"
main()
{
chara,b;
a=getchar();scanf("%d",&b);
a=a-'A'+'0';
b=b*2;
printf("%c %c\n",a,b);
}
(12)以下程序中,fun函数的功能是求3行4列二维数组每行元素中的最大值.请填空. br[i]
void fun(int,int,int(*)[4],int*)
main()
{
int a[3][4]={{12,41,36,28},{19,33,15,27},{3,27,19,1}},b[3],i;
fun(3,4,a,b);
for(i=0;i<3;i++)
printf("%4d",b[i]);
printf("\n");
}
voidfun(int m,intn,intar[][4],int*br)
{
inti,j,x;
for(i=0;i { x=ar[i][0];
for(j=0;j if(x 【12】 =x;
}
(13)以下程序运行后的输出结果是4 3 3 4
voidswap(int x,inty)
{ int t;
t=x;x=y;y=t;
printf("%d %d ",x,y);
}
main()
{ int a=3,b=4;
swap(a,b);
printf("%d %d\n",a,b);
}
(14)以下程序运行后的输出结果是 abcfg
#include"string.h"
voidfun(char *s,intp,intk)
{ inti;
for(i=p;i s[i]=s[i+2];
}
main()
{ char s[]="abcdefg";
fun(s,3,strlen(s));
puts(s);
}
(15)以下程序运行后的输出结果是abcbcc
#include"string.h"
main()
{
char ch[]="abc",x[3][4];int i;
for(i=0;i<3;i++) strcpy(x[i],ch);
for(i=0;i<3;i++) printf("%s",&x[i][i]);
printf("\n");
}
(16)以下程序运行后的输出结果是 0 10 1 11 2 12
fun(int a)
{
intb=0;static intc=3;
b++; c++;
return (a+b+c);
}
main()
{
inti,a=5;
for(i=0;i<3;i++)
printf("%d%d ",i,fun(a));
printf("\n");
}
(17)以下程序运行后的输出结果是 13431
struct NODE
{ int k;
structNODE *link;
};
main()
{
struct NODE m[5],*p=m,*q=m+4;
int i=0;
while(p!
=q)
{ p->k=++i; p++;
q->k=i++; q--;
}
q->k=i;
for(i=0;i<5;i++)
printf("%d",m[i].k);
printf("\n");
}
(18)以下程序中函数huiwen的功能是检查一个字符串是否是回文,当字符串是回文时,函数返回字符串:
yes
yes!
否则函数返回字符串:
no!
并在主函数中输出.所谓回文即正向与反向的拼写都一样,例如:
adgda.请填空.
#include "string.h"
char *huiwen(char *str)
{
char*p1,*p2; int i,t=0;
p1=str; p2= ①
for(i=0;i<=strlen(str)/2;i++)
if(*p1++!
=*p2--)
{ t=1;break; }
if(②) return("yes!
");
else return("no!
");
}
main()
{
char str[50];
printf("Input:
"); scanf("%s",str);
printf("%s\n", ③ );
}
①str+strlen(str)-1
②t==0或!
t
③huiwen(str)
[完]