下面程序段的执行结果是int a,b,c,t; a=1; b=2; c=2; while(a<b<c) { t=a; a=b; b=t; c--; } cout<<a<<","<<b<<","<<c<<endl;A.1,2,0B.1,1,0C.2,1,1D.2,1,0

下面程序段的执行结果是int a,b,c,t; a=1; b=2; c=2; while(a<b<c) { t=a; a=b; b=t; c--; } cout<<a<<","<<b<<","<<c<<endl;

A.1,2,0

B.1,1,0

C.2,1,1

D.2,1,0


参考答案和解析
B

相关考题:

执行下面程序输出的是【】。 include using namespace std;template T tot 执行下面程序输出的是【 】。include <iostream>using namespace std;template <typename T>T total(T *data){Ts=0;while( *data) s+=*data++;return s;}int main(){int s[]={1,3,5,7,0,2,4,6,8};cout<<total(s);return 0;}

下列程序执行结果是()。includeclass A{public:int a;A():a(10){cout 下列程序执行结果是( )。 #include<iostream.h> class A {public: int a; A():a(10){cout<<a<<endl;} }; void main() { A obj1; A obj2(obj1); cout<<""((obj2.a<<endl; )A.10 10B.编译错误缺少拷贝构造函数C.10随机数D.随机数随机数

有下列程序: main() { int t,a=1,b=5,c=-2; while(a>b>C) { t=a;a=b;b=t;c++;} printf("%d,%d,%d",a,b,c); } 程序的输出结果是( )。A.1,5,0B.1,5,-2C.5,1,-1D.5,1,-2

下面程序段的运行结果是void main(){int t,a,b,c;a=1;b=2;c=2:while(a{t=a;a=b;b=t;c--;}cout }A.1,2,0B.2,1,0C.1,2,1D.2,1,1

有如下程序:includevoid fun(intx, int y){int t=x; x=y; y=t;}int main(){int 有如下程序: #include<iostream> void fun(intx, int y){int t=x; x=y; y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::end1; return 0; } 执行后的输出结果是( )。A.42,42B.23,23C.23,42D.42,23

下列程序段执行后t5的结果是( )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3; A.8B.20C.11D.9

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】设计一个类模板SamPle用于对一个有序数组采用二分法查找元素下标。【C++程序】include < iostream. h >define Max 100 //最多元素个数template < class T >class Sample{T A[Max]: //存放有序数序int n: //实际元素个数publicSample( ) { } //默认构造函数Sample(T a[] ,int i); //初始化构造函数int seek(T c);void disp( ){for(int i=0;i <n;i ++)cout<<A[i] <<" ";cout<<endl:} } template < class T >Sample <T>: :Sample(T a[ ],int i){n=i:for( intj =0;j < i;j ++ )(1);}template < class T >int Sample < T >:: seek( T c){int low =0,high = n-1 ,mid;while((2)){mid = (low + high)/2;if((3))return mid;else if( (4) )low=mid+|;else(5);}return-1;}void main( ){char a[ ] ="acegkmpwxz";Sample < char > s(a, 1);cout<<"元素序列:" ;s. disp( );cout<<"元素'g'的下标:"<<s. seek('g') <<endl;}

下列程序执行的结果是()。A=1;b=2;c=3;While(bac){t=a;a=b;b=t;c--;}printf(“%d,%d,%d”,a,b,c); A.1,2,0B.2,1,0C.1,2,1D.2,1,1

下面程序段的运行结果是 void main() { int t,a,b,c; a=1;b=2;C=2; while(a<b<c) { t=a;a=b;b=t;c--;} cout << a << " ," << b << " ," << c; }A.1,2,0B.2,1,0C.1,2,1D.2,1,1

有如下程序:include void fun (int x,int y){int t=x;x=y;y=t;}int main(){ int 有如下程序: #include <iostream> void fun (int x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun (a[1],a[0]; std::cout<<a[0]<<”,”<<a[1]<<std:: ond1; retum0; }执行后的输出结果是______ 。A.41,41B.23,23C.13,42D.42,23

下列程序的输出结果是【】 includeusing namespace std; template T total 下列程序的输出结果是【 】include<iOStream>using namespace std;template <typename T>T total (T*datA){T s=0;while(*datA){s+=*data++;}return s;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x)<<end1;return 0;}

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】以下程序的功能是设计一个栈类stack<T>,并建立一个整数栈。【程序】include < iostream. h >include < stdlib. h >const int Max =20; //栈大小template < class T >class stack{ //栈元素数组T s[Max]; //栈顶下标int top;public:stack( ){top =-1; //栈顶初始化为-1}void push( const T item); //item入栈T pop( ); //出栈int stackempty( ) const; //判断栈是否为};template < class T >void stack <T >::push(const T item){if(top==(1)){cout <<"栈满溢出" <<endl;exit(1);}top ++s[top] = item;}template < class T >T stack<T> ::pop(){T temp;if(top==(2)){cout <<"栈为空,不能出栈操作" < < endl;exit(1);}temp =s[top];top --;return temp;}template < class T >int stack < T >:: stackempty( ) const{ return top == -1;{void main( ){stack <int> st;int a[] ={1,2,3,4,5};cout <<"整数栈" <<endl;cout <<"入栈序列:" <<endl;for(int i=0;i<4;i ++){cout <<a[i] <<" ";(3);}cout << endl <<"出栈序列";while((4))tout<<(5)<<" ";cout< < endl;}

下面程序的运行结果是( )。include define SlZE 12 main() {char s[SIZE];int i;for(i=0 下面程序的运行结果是( )。include<stdio.h>define SlZE 12main(){char s[SIZE];int i;for(i=0;i<SIZE;i++) s[i]='A'+i+32;sub(s,5,SIZE-1);for(i=0;i<SIZE;i++)printf("%c",s[i]);printf("\n");}sub(char *a,int t1,int t2){ char ch;while(t1<t2){ ch=*(a+t1);*(a+t1)=*(a+t2);*(a+t2)=ch;t1++;t2--;}}

下列程序的输出结果是______。 include template T max(T x[],int n) { int 下列程序的输出结果是______。include<iostream.h>template<class T>T max(T x[],int n){int i;T maxv=x[0];for(i=1;i<n;i++)if(maxv<x[i])maxv=x[i];return maxv;}void main( ){int a[]={3,2,7,6,8,9};double b[]={1.2,3.4,2.5,7.3,6.8};cout<<max(a,4)<<","<<max(b,3)<<endl;}

有如下程序:include void fun(int x, int y){int t=x;x=y;y=t;}int main (){int 有如下程序: #include <iostream> void fun(int x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是A.42,42B.23,23C.23,42D.42,23

下面程序的输出结果是()。includeusing namespace std;void swap(int x[2]){int t; t= 下面程序的输出结果是( )。 #include<iostream> using namespace std; void swap(int x[2]) { int t; t=x[0]; x[0]=x[1]; x[1]=t; } void main() { int a[2]={4,8}; swap(a); cout<<a[0]<<" "<<a[1]; }A.4 8B.8 4C.4 4D.8 8

下面程序的结果是includeclass A{int a;public:A( ) :a(1) {}void showa ( ) {cout 下面程序的结果是 #include<iostream.h> class A { int a; public: A( ) :a(1) {} void showa ( ) {cout < < a;} }; class B { int a; public: B( ) :a(2) {} void showa( ) {cout < < a;} }; class C: public A, public B { t a; public: C( ) :a(3) {} void showa( ) {cout < < a;} }; void main( ) { C c; c.showa( ) ; }A.1B.2C.3D.程序有错误

如下程序的输出结果是includevoid fun(int x=y;y=t;}int main(){in 如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }A.42,42B.23,23C.23,42D.42,23

程序的结果为______。include"iostream.h" template T total(T*data) { Ts=0; while( 程序的结果为______。include"iostream.h"template<typename T>T total(T*data){Ts=0;while(*data){S+=*data++;}return S;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x);retum 0;cout<<endl;}

以下程序的输出结果是()。includemain(){int b[3][3]={0,1,2,0,1,2,0,1,2},ij,t=1;f 以下程序的输出结果是( )。 #include<iostream.h> main() { int b[3][3]={0,1,2,0,1,2,0,1,2},ij,t=1; for(i=0;i<3;i++) for(j=i;j<=i;j++) t=t+b[i][b[j][j]; cout<<t; }A.3B.4C.1D.9

有下列程序 main() { int t, a=1, b=5, c=-2; while(a>b>c) { t=a; a=b; b=t; c++;} printf("%d, %d, %d", a, b, c); } 程序输出的结果是( )。A.1, 5, 0B.1, 5, -2C.5, 1, -1D.5, 1, -2

下面程序的运行结果是#include #define SIZE 12sub(char *a,int t1,int t2) { char ch; while(t1t2) { ch=*(a+t1); *(a+t1)=*(a+t2); *(a+t2)=ch; t1++;t2--; }} main() { char s[SIZE]={’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’}; int i; sub(s,7,SIZE-1); for(i=0;iSIZE;i++) printf("%c ",s[i]); printf("\n");}

以下程序的输出结果是()。//includemain(){ int b[3][3]={0,1,2,0,1,2,0,1,2},i,j, t 以下程序的输出结果是( )。 //include<iostream.h> main() { int b[3][3]={0,1,2,0,1,2,0,1,2},i,j, t=1; for(i=0,i<3; i+ +) for(j=i;j<=i; j+ +) t=t+b[i][b[j][j]]; cout<<t; }A.3B.4C.1D.9

下面程序的输出结果是()。includeusing namespace std;templateT max(T x,T 下面程序的输出结果是( )。 #include<iostream> using namespace std; template<class T> T max(T x,T y) { return(x>= y ? x:y);} template<class T> T max(T x,T y,T z) { T t; t=(x>=y ? x:y); return(t>=z ? t:z); } void main(){ int x = 10,y=18,maxi; float a = 1.2,b = 3.2,c = 2,max2; max1 = max(x,(int)c); max2 = max(a,b,(float)y); cout<<maxi<<endl; cout<<max2<<endl;A.18 3.2B.10 18C.10 3.2D.编译出错

有以下程序main( ){ int a=5,b=4,c=3,d=2;if(a>b>c)cout<<d<<endl;else if((c-1=d)==1)cout<<d+1<<endl;elsecout<<d+2<<endl;}执行后输出结果是A.2B.3C.4D.编译时有错,无结果

下列程序段的执行结果是______。 int i=0; while(i++<=2) printf("%d\t",i);A.1 2 3B.1 2C.1D.无结果

有如下程序段:int x=3,do{ x-=2;cout<<x;}while(!(--x));执行这个程序段的输出结果是( )。A.1B.30C.1-2D.死循环

有如下程序:inchdevoid fun(int x,int y){int t=x;x=y;y=t;}int main(){int a 有如下程序: #inchde<iostream.h> void fun(int x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42); fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<Std::endl; return 0; } 执行后的输出结果是( )。A.42,42B.23,23C.23,42D.42,23