全部题库 / C语言 / 试题详情
单选题 C语言
2013-08-15

有以下程序:
#include<stdio.h>
#include<string.h>
main(  )
{ char a[5][10]={"china","beijing","you","tiananmen","welcome");
 int i,j;char t[10];
 for(i=0;i<4;i++)
  for(j=i+1;j<5;j++)
   if(strcmp(a[i],a[j]>O)
   {strcpy(t,a[i]);strepy(a[i],a[j]);strcpy(a[j],t)};
 puts(a[3]);
}
程序运行后的输出结果是(  )。

A.beijing   
B.china   
C.welcome
D.tiananmen

参考答案

C

答案解析

此题涉及数组,字符串的比较和字符串的复制,因为for循环中控制数组中的i和j,即控制了其中的数组中的元素,而stremp是比较字符串的大小,如果stremp(a[i],a[j])>0,则将字符串进行复制,所以答案为C。

你可能感兴趣的试题