试题通
试题通
APP下载
首页
>
IT互联网
>
信息技术知识竞赛c语言
试题通
搜索
信息技术知识竞赛c语言
题目内容
(
单选题
)
以下程序中函数f的功能是:当flag为4时,进行有小到大排序;当flag为0时,进行由大到小排序。
void f(int b[],int n,int flag)
{int i,j,t;
for(i=0;ifor (j=0;jif(flag?b[j]>b[j+1]:b[j]{t=b[j];b[j]=b[j+1];b[j+1]=t;}}
main()
{int a[10]={5,4,3,2,1,6,7,8,9,10},I;
f(&a[2],5,,0); f(a,5,1);
for(i=0;i<10;i++) printf(“%d,”a[ i ]);}
程序运行后的输出结果是()。

A、1,2,3,4,5,6,7,8,9,10,

B、3,4,5,6,7,2,1,8,9,10,

C、5,4,3,2,1,6,7,8,9,10,

D、10,9,8,7,6,5,4,3,2,1,

答案:B

试题通
信息技术知识竞赛c语言
试题通
有以下程序
fun(int x,int y){return(x+y);}
main()
{int a=1,b=2,c=3,sum;
sum=fun((a++,b++,a+b),c++);
printf("%d\n",sum); }
执行后的输出结果是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e034651c.html
点击查看题目
有以下程序
#include
# include
char *fun(char *t)
{
char *p=t;
return(p+strlen(t)/2);
}
void main()
{
char *str="abcdefgh";
str=fun(str);
puts(str);
}
执行后的输出结果是( )。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6c48-c089-2897e0346500.html
点击查看题目
有以下程序
main()
{int a=0,b=0,c=0,d=0;
if(a=1) b=1;c=2;
else d=3;
printf("%d,%d,%d,%d\n",a,b,c,d);
}
程序输出()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e0346511.html
点击查看题目
8、 有以下程序
struct STU{
char name[10];
int num;
};
void f1(struct STU c)
{ struct STU b={"LiSiGuo",2042};
c=b;}
void f2(struct STU *c)
{ struct STU b={"SunDan",2044};
*c=b;
}
main( )
{ struct STU a={"YangSan",2041},b={"WangYin",2043};
f1(a);f2(&b);
printf("%d %d\n",a.num,b.num);}
执行后的输出结果是 ()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e0346503.html
点击查看题目
有以下程序
main()
{int a=1,b=3,c=5;
int *p1=&a,*p2=&b,*p=&c;
*p=*p1*(*p2);
printf("%d\n",c);
}
执行后的输出结果是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e0346500.html
点击查看题目
有以下程序段
struct st
{int x;int *y;}*pt;
int a[]={1,2},b[]={3,4};
struct st c[2]={10,a,20,b};
pt=c;
以下选项中表达式的值为11的是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4d08-c089-2897e0346529.html
点击查看题目
在调用函数时,如果实参是简单变量,它与对应形参之间的数据传递方式是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4d08-c089-2897e034650a.html
点击查看题目
有以下程序
main()
{int k=5,n=0;
do
{switch(k)
{case 1: case 3:n+=1; break;
default:n=0;k--;
case 2: case4:n+=2;k--;break;}
printf(“%d”,n);
}while(k>0&&n<5);}
程序运行后的输出结果是()
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e0346507.html
点击查看题目
设实型变量为f1、f2、f3、f4的值分别为4,3,2,1整型变量m1、m2
的值为1。表达式“(m1=f1>f2)&&(m2=f3
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4920-c089-2897e034650c.html
点击查看题目
有以下程序
#include
void fun(char *s)
{ while(*s)
{ if (*s%2==0) printf("%c",*s);
s++;
}
}
void main()
{
char a[]={"good"};
fun(a);
printf("\n");
}
执行后的输出结果是( )。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6c48-c089-2897e0346503.html
点击查看题目
首页
>
IT互联网
>
信息技术知识竞赛c语言
题目内容
(
单选题
)
手机预览
试题通
信息技术知识竞赛c语言

以下程序中函数f的功能是:当flag为4时,进行有小到大排序;当flag为0时,进行由大到小排序。
void f(int b[],int n,int flag)
{int i,j,t;
for(i=0;ifor (j=0;jif(flag?b[j]>b[j+1]:b[j]{t=b[j];b[j]=b[j+1];b[j+1]=t;}}
main()
{int a[10]={5,4,3,2,1,6,7,8,9,10},I;
f(&a[2],5,,0); f(a,5,1);
for(i=0;i<10;i++) printf(“%d,”a[ i ]);}
程序运行后的输出结果是()。

A、1,2,3,4,5,6,7,8,9,10,

B、3,4,5,6,7,2,1,8,9,10,

C、5,4,3,2,1,6,7,8,9,10,

D、10,9,8,7,6,5,4,3,2,1,

答案:B

试题通
试题通
信息技术知识竞赛c语言
相关题目
有以下程序
fun(int x,int y){return(x+y);}
main()
{int a=1,b=2,c=3,sum;
sum=fun((a++,b++,a+b),c++);
printf("%d\n",sum); }
执行后的输出结果是()。

A. 6

B. 7

C. 8

D. 9

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e034651c.html
点击查看答案
有以下程序
#include
# include
char *fun(char *t)
{
char *p=t;
return(p+strlen(t)/2);
}
void main()
{
char *str="abcdefgh";
str=fun(str);
puts(str);
}
执行后的输出结果是( )。

A. efgh

B. abcd

C. bcde

D. cdef

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6c48-c089-2897e0346500.html
点击查看答案
有以下程序
main()
{int a=0,b=0,c=0,d=0;
if(a=1) b=1;c=2;
else d=3;
printf("%d,%d,%d,%d\n",a,b,c,d);
}
程序输出()。

A. 0,1,2,0

B. 0,0,0,3

C. 1,1,2,0

D. 编译有错

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e0346511.html
点击查看答案
8、 有以下程序
struct STU{
char name[10];
int num;
};
void f1(struct STU c)
{ struct STU b={"LiSiGuo",2042};
c=b;}
void f2(struct STU *c)
{ struct STU b={"SunDan",2044};
*c=b;
}
main( )
{ struct STU a={"YangSan",2041},b={"WangYin",2043};
f1(a);f2(&b);
printf("%d %d\n",a.num,b.num);}
执行后的输出结果是 ()。

A. 2041 2044

B. 2041 2043

C. 2042 2044

D. 2042 2043

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-58c0-c089-2897e0346503.html
点击查看答案
有以下程序
main()
{int a=1,b=3,c=5;
int *p1=&a,*p2=&b,*p=&c;
*p=*p1*(*p2);
printf("%d\n",c);
}
执行后的输出结果是()。

A. 1

B. 2

C. 3

D. 4

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e0346500.html
点击查看答案
有以下程序段
struct st
{int x;int *y;}*pt;
int a[]={1,2},b[]={3,4};
struct st c[2]={10,a,20,b};
pt=c;
以下选项中表达式的值为11的是()。

A. *pt->y

B. pt->x

C. ++pt->x

D. (pt++)->x

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4d08-c089-2897e0346529.html
点击查看答案
在调用函数时,如果实参是简单变量,它与对应形参之间的数据传递方式是()。

A. 地址传递

B. 单向值传递

C. 由实参传给形参,再由形参传回实参

D. 传递方式由用户指定

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4d08-c089-2897e034650a.html
点击查看答案
有以下程序
main()
{int k=5,n=0;
do
{switch(k)
{case 1: case 3:n+=1; break;
default:n=0;k--;
case 2: case4:n+=2;k--;break;}
printf(“%d”,n);
}while(k>0&&n<5);}
程序运行后的输出结果是()

A. 2345

B. 235

C. 23456

D. 2356

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e0346507.html
点击查看答案
设实型变量为f1、f2、f3、f4的值分别为4,3,2,1整型变量m1、m2
的值为1。表达式“(m1=f1>f2)&&(m2=f3

A. 0

B. 1

C. 2

D. 出错

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-4920-c089-2897e034650c.html
点击查看答案
有以下程序
#include
void fun(char *s)
{ while(*s)
{ if (*s%2==0) printf("%c",*s);
s++;
}
}
void main()
{
char a[]={"good"};
fun(a);
printf("\n");
}
执行后的输出结果是( )。

A. a

B. b

C. c

D. d

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6c48-c089-2897e0346503.html
点击查看答案
试题通小程序
试题通app下载