• 2022-06-09
    以下程序的运行结果是s=2,t=3#include ;using namespace std;int main(){ int s=1,t=1,a=5,b=2; if (a>;0) s++; if (a>;b) t+=s; else if (a==b) t=5; else t=2*s; cout return 0;}
  • 内容

    • 0

      以下程序的运行结果是________。 #include “stdio.h” void main() { int a,b,c,s,w,t; s=w=t=0; a= -1; b=3; c=3; if (c>0) s=a+b; if (a<=0) { if (b>0) if(c<=0) w=a-b;} else if(c>0) w=a-b; else t=c; printf("%d %d %d", s,w,t); }

    • 1

      以下与库函数strcmp(char *s,char *t)功能相等的程序段是( )。? int strcmp3(char *s,char *t){ for ( ; *t==*s; ) { if (!*t) return 0 ; t++ ; s++ ; } return (*s-*t) ;}|int strcmp2(char *s,char *t){ for ( ; *s++==*t++; ) if (!*s) return 0 ; return (*s-*t) ;}|int strcmp1(char *s,char *t){ for ( ; *s++==*t++; ) if (*s=='\0') return 0 ; return (*s-*t) ;}|int strcmp4(char *s,char *t){ for ( ; *s==*t;s++,t++ ) if (!*s) return 0 ; return (*t-*s) ;}

    • 2

      对于如下程序:#include [stdio.h] int s(char *,char *); int main(){ char a[20]; char b[10]; char *p; char *q; int i; p=a; q=b; scanf("%s%s",a,b); i=s(a,b); printf("%d",i);} int s(char *s,char *t){ while(*s!='\0' && *t!='\0'){ if(*s= =*t){ s++; t++; } else return *s-*t; } return *s-*t;}如果输入流是12 13,程序的输出是什么? A: -1 B: 1 C: 0 D: 2

    • 3

      中国大学MOOC: 下面程序执行后的输出结果是:#include <iostream>using namespace std;void ss(char *s,char t){while(*s) {if(*s==t) *s=t-a+A;s++;}}int main(){char str1[100]="abcddfefdbd",c=d;ss(str1,c); cout<<str1;return 0;}

    • 4

      ‏执行下面程序段,若输出结果t=4,则a和b输入的值应满足的条件是( )。‎‏ int s,t,a,b;‎‏ scanf("%d,d",&a,&b); ‎‏ s=1,t=1; ‎‏ if (a>0) s=s+1; ‎‏ if (a>b) t=s+t;‎‏ else if (a==b) t=5; ‎‏ else t=2*s; ‎‏ printf("t=%d\n",t);‎‏‎ A: a>b B: a<b<0 C: 0<a<b D: 0>a>b