首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

写出下列程序的执行结果。 swap(p1,p2) int*p1,*p2; {int p; p=*p1;*p1=*p2;*p2=p; } main() {int

写出下列程序的执行结果。 swap(p1,p2) int*p1,*p2; {int p; p=*p1;*p1=*p2;*p2=p; } main() {int a,b,*p1,*p2; scanf("%d%d",&a,&B); p1=&a;p2=&b; if(a<B)swap(p1,p2); printf("\na=%d,b=%d\n",a,B); } 若a=7,b=8,则程序的运行结果为()。

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“写出下列程序的执行结果。 swap(p1,p2) int*p…”相关的问题
第1题
请写出如下程序的输出结果:#include void Swap( int &a, int & b);void main(){int
请写出如下程序的输出结果:#include void Swap(int &a, int & b);void main(){int

请写出如下程序的输出结果:

#include void Swap(int &a, int & b);void main(){int x(10 ), y(7 );

cout<< "x="<< x<< " y="<< y<< endl;Swap(x , y );cout<< "x="<< x<< " y="<< y<< endl;

}void Swap(int & a, int & b){ int temp; temp = a ; a=b ; b=temp ; }

点击查看答案
第2题
●在下列程序中:Program test(input,output);var i,j:integer;procedure calc(p1,p2:integer);beg

●在下列程序中:

Program test(input,output);

var i,j:integer;

procedure calc(p1,p2:integer);

begin p2:=p2*p2 p1:=p1-p2;p2:=p2-p1;end{caic}

begin{main}i:=2;j:=3;

calc(i,j); write(j);

end{main}

当参数传递采用引用方式(Call by reference)时,所得结果j= (33) ;

当参数传递采用换名方式(Call by name)时,所得结果j= (34) ;

当参数传递采用赋值方式(Call by value)时,所得结果j= (35) ;

递归是程序设计中很重要的一种控制结构,通常实现递归时,采用的数据结构是 (36) 。

对那些既可以用递归方式,也可以用循环方式求解的问题,就执行效率而言 (37) 。

(33) ,(34) A.10

B.16

C.20

D.28

(35) A.0

B.3

C.5

D.6

(36) A.数组

B.栈

C.队列

D.循环链表

(37) A.数组

B.两者相同

C.循环优于递归

D.递归优于循环

点击查看答案
第3题
下面程序的运行结果为()。 #include<iostream> using namespace std; void swap(int &

下面程序的运行结果为()。 #include<iostream> using namespace std; void swap(int &a,int &b){ int temp; temp=a; a=b; b=temp; } void main(){ int a=2,b=3; swap(a,b); cout<<a<<"," <<b<<ENDL; }

A.2,3

B.3,2

C.2,2

D.3,3

点击查看答案
第4题
有以下程序: void swap(char*x,char*y) {cbar t; t=*x; *x=*y; *y=t; } main() {char*s1="abc",*s2="123"; swap(s1,s2);printf("%s,%s\n",s1,s2); } 程序执行后的输出结果是()。

A.123,abc

B.abc,123

C.1bc,a23

D.321,cba

点击查看答案
第5题
下面程序的运行结果为()。def swap(list): temp=list[0] list[0]=list[1] list[1]=templist=[1,2]swap(list)print(list)

A.[1,2]

B.[2,1]

C.[2,2]

D.[1,1]

点击查看答案
第6题
分析下列程序:#include<stdio.h>main(){ int*p1,*p2,*p;int a=6,b=9;p1=&a;p2=&b;if(a<b

分析下列程序: #include<stdio.h> main() { int*p1,*p2,*p; int a=6,b=9; p1=&a;p2=&b; if(a<b){p=p1;p1=p2;p2=p;} printf("%d,%d",*p1,*p2); printf("%d,%d",a,b); } 程序的输出结果为()。

A.9,6 6,9

B.6,9 9,6

C.6,9 6,9

D.9,6 9,6

点击查看答案
第7题
有以下程序 void swap(char *x,char *y) {char t; t=*x;*x=*y;*y=t; } main() {char *s1="abc",*s2="123"; swap(s1,s2); printf("%s,%s\n",s1,s2); } 程序执行后的输出结果是______。

A.123,abc

B.abc,123

C.1bc,a23

D.321,cba

点击查看答案
第8题
有以下程序:#include <stdio.h>void swap(char * x,ehar * y){ char t;t= *x; *x: *y; *y=t;main

有以下程序:#include <stdio.h>void swap(char * x,ehar * y){ char t; t= *x; *x: *y; *y=t;main (){ char *s1 ="abc", * s2 ="123"; swap(s1 ,s2); printf("%s,%s \n" ,s1 ,s2);}程序执行后的输出结果是()。

A.123,abe

B.abe,123

C.1bc,a23

D.321,cba

点击查看答案
第9题
在下列程序中: Program test(input, output); var i. j:integer; procedure calc(p1, p2: intege

在下列程序中:

Program test(input, output);

var i. j:integer;

procedure calc(p1, p2: integer);

beginp2: = p2 * p2 p1: = p1 - p2; p2: = p2 - p1; end {caic}

begin {main} i: =2;j:=3;

calc(i,j); write(j);

end {main}

当参数传递采用引用方式(Call by reference)时,所得结果j=(6);

当参数传递采用换名方式(Call by name)时,所得结果,j=(7);

当参数传递采用赋值方式(Call by value)时,所得结果,j=(8)。

A.3

B.6

C.10

D.16

点击查看答案
第10题
下面程序的运行结果为()。#include<iostream.h> voidswap(int&a,intb) { inttemp; temp=

下面程序的运行结果为()。#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; }

A.2,3

B.3,2

C.2,2

D.3,3

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改