目录: 标题| 题干| 答案| 搜索| 相关
问题

下列程序的运行结果是( )。 #include<stdio.h> #incl


下列程序的运行结果是( )。 #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不确定的值
参考答案
参考解析:

解析:本题考查字符串比较函数和两个字符串比较的原则两个知识点,①原则是依次比较两个字符串同一位置的 对字符,若它们的ASCII码值相同,则继续比较下一对字符,若它们的ASCII码值不同,则ASCII码值较大的字符所在的字符串较大;若所有字符相同,则两个字符串相等;若一个字符串全部i个字符与另一个字符串的前i个字符相同,则字符串较长的较大。②strcmp(s1,s2)的返回值,当 str1str2时,返回值0;当str1=str2时,返回值为0;当str1>str2,返回值>0。

分类:其他
相关推荐

1、下列程序的执行结果是_______。 #include<stdio.h> u

下列程序的执行结果是_______。 #include<stdio.h> union un { int i; char c[2]; }; void main() { union un x; x.c[0]=10; x.c[1]=1; printf(" %d",x.i); }A266B11C265D138

2、下列程序的输出结果是( )。 #include<stdio.h> int f

下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int a; if(x==0‖x==1) return 3; else a=x-fun(x-2); return a; } void main() { printf("%d",fun(7)); }A2B8C9D5

3、下面这个程序的结果是 #include<iostream.h> class

下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta( );int geta( );}; void A::seta( ) { a = 1;} int A::geta( ) {return a;} classA1B2C随机输出1或2D程序有错

4、下面程序的运行结果为( )。include<iostream.h>voids

下面程序的运行结果为( )。include<iostream.h>voidswap(int&a,intb) { inttemp; temp=a++; a=b: b=temp: } voidmain() { inta=2,b=3; swap(a,b); cout<<a<<","<<b<<endl; }A2,3B3,2C2,2D3,3

5、下列程序的输出结果是( )。 #include<iostream> usin

下列程序的输出结果是( )。 #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){retum i;} }; int TestClass∷i=0; voiA111B121C211D221

6、下列程序段的输出结果为( )。 #include<stdio.h> main

下列程序段的输出结果为( )。 #include<stdio.h> main() { static char a[]="language"; char *p; p=a; for(p=a;p<a+8;p+=2) putchar(*p); }AlanguageBlnugC有语法错误Dlang