有以下程序
#include <stdio.h>
struct tt
{ int x;struct tt *y;} *p;
struct tt a[4]={20,a+1,15,a+2,30,a+3,17,a};
main()
{ int i;
p=a;
for(i=1;i<=2;i++) {printf("%d,",p->x); p=p->y;}
}
程序的运行结果是
A)20,30,
B)30,17
C)15,30,
D)20,15,
第1题:
下列给定程序中,函数fun()的作用是:将字符串tt中的小写字母都改为对应的大写字母,其他字符不变。例如,若输入“edS,dAd”,则输出“EDS,DAD”。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <string.h>
include <conlo.h>
/*************found*************/
char fun(char tt[ ])
{
int i;
for(i=0;tt[i];i++)
{
/*************found*************/
if((tt[i]>='A')&&(tt[i]<='2'))
tt[i]-=32;
}
return(tt);
}
main()
{
int i;
char tt[81];
clrscr();
printf("\nPlease enter a string:");
gets(tt);
printf("\nThe result string iS:/n%s", fun(tt));
}
第2题:
下列语句段中,正确的是( )。
A.struct {int x; float y; int a[2]; unsigned b[3]; char name[10]; };
B.structstu { unsigneda[3]; unsigned b[4]; }x; int*p=&x.a;
C.struc tsu { int a; float x[4]; }y={1,1.0}; floatdat a=y.x;
D.stmct nd {int a,b; unsigned c[2]=5; };
第3题:
下列语句段中,正确的是( )。
A.struct { int x; float y; int a[2]; unsigned b[3]; char name[ 10]; };
B.struct stu { unsigned a[3]; unsigned b[4]; }x; int *p=& x.a;
C.street stu { int a; float x[4]; }y={1,1.0}; float data=y.x;
D.struct nd {int a,b; unsigned c[2]=5; };
第4题:
设有以下语句:typedef struct TY{char C;int a{4 1;}CIN;
则下面叙述中正确的是( )。
A.CIN是struct Tr类型的变量
B.TT是struct类型的变量
C.可以用,lr定义结构体变量
D.可以用CIN定义结构体变量
第5题:
设有以下语句: typedef struct TT {char c; int a[4];}CIN; 则下面叙述中正确的是( )。
A.可以用TT定义结构体变量
B.TT是struct类型的变量
C.可以用CIN定义结构体变量
D.CIN是struct TT类型的变量
第6题:
对于以下的变量定义,表达式______是不正确的。 struct { float x, y; } point, *p=&point;
A.p->x=2.0
B.(*p).y=3.0
C.point.x=2.0
D.*p->y=3.0