下面程序和运行运行结果是【 】。
typedef union student
{ char name [10];
long sno;
char sex;
float score [4];
} STU;
main ( )
{ STU a[5];
prinff( "% d\n", sizeof(a) );
}
第1题:
下面程序的运行结果是( )。 #include<stdio.h> #include<string.h> main() {char*s1="abDuj"; char*s2="ABdUG"; int t; t=strcmp(s1,s2); printf("%d",t); }
A.正数
B.负数
C.零
D.不确定的值
第2题:
下面程序的运行结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char * a="AbcdEf",* b="aBcD" a + +;b + +; printf("%d\n",strcmp(a,b)); }
A.0
B.负数
C.正数
D.无确定值
第3题:
以下程序的结果是 #include<iostream.h> void main( ) { char * p="abcdefgh",* r; long * q; q=(long * )p; q++; r=(char * )q; cout < < r < < end1;}
A.defg
B.cdef
C.ghab
D.efgh
第4题:
下面程序的运行结果是 #include<stdio.h> #include<string.h> main() { char*s1="AbDeG"; char*s2="AbdEg"; s1+=2;s2+=2; printf("%d\n",strcmp(s1,s2)); }
A.正数
B.负数
C.零
D.不确定的值
第5题:
有如下程序: #include<iostream> using namespace std; class Toy{ public: Toy(char*_n){strcpy(name,_n);count++;} ~Toy(){count--;} char*GetName( ){return name;} static int getCount( ){return count;} private: char name[10]; static int count; }; int Toy::count=0: int main( ){ Toy tl("Snoopy"),t2("Mickey"),t3("Barbie"); cout<<t1.getCount( )<<endl; return 0; } 程序的输出结果是
A.1
B.2
C.3
D.运行时出错
第6题:
下面程序的运行结果是( )。 #include<stdio.h> void delch(char *s) { int i,j; char*a; a=s; for(i=0,j=0;a[i]!='\0' ;i++) if(a[i]>='0' &&a[i]<='9') { s[j]=a[i]; j++;} s[j]='\0'; } main() { char*item="a34bc"; delch(item); printf("\n%s" ,item);}
A.abc
B.34
C.a34
D.a34bc