1、下述代码中,statement应该如何写才能使得程序输出1 int t = 1; try { ...... throw t; ...... } catch (statement ) { cout << i; }A.int iB.float iC.unsigned int iD.exception i

1、下述代码中,statement应该如何写才能使得程序输出1 int t = 1; try { ...... throw t; ...... } catch (statement ) { cout << i; }

A.int i

B.float i

C.unsigned int i

D.exception i


参考答案和解析
int i

相关考题:

函数Min的功能是返回具有n个元素的数组array中的最小值。请将横线处的缺失部分补充完整,使得程序的输出结果为1.24。include<iostream>using namespace std;template<typename T>T Min(T*array, int n){T min=array[0];for(int i=1; i<n; i++)if(array[i]<min)min=array[i];return min;}int main(){double art[8]={5.2, 48.45, 41.01, 42, 51.2, 1.24, 14.12, 42};cout<<______;return 0:}

使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错误,请改正错误,使程序正常运行,并且要求最后一个catch必须抛出执行的任何异常。程序异常,输出信息为errorOERROR注意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在//******error******的下面。试题程序:includeiostream.h)intmain{try{throw(error);}//********error********catch(chars){coutsendl;}try{throw((int)0);}//********error********catch{coutiendl;}try{throw(O);throw(error);}//********error********catch{coutERRORendl;}return0;}

以下程序的输出结果是#include(iostream. hvoid reverse(int a[],int n){ int i,t;for(i=0;;{t=a[i];a[i]=a[n-1-i];a[n-1-i]=t;}}void main(){ int b[10]={1,2,3,4,5,6,7,8,9,10};int i,s=0;reverse(b,8);for(i=6;i 10;i++)s+=b[i];cout }A.22B.10C.34D.30

在下面程序横线处填上适当内容,使得程序的输出为9876。include using namespace std;te 在下面程序横线处填上适当内容,使得程序的输出为9876。include <iostream>using namespace std;template<class T>void f(【 】){T t;for (int i=0;i<n/2;i++){t=a Ii];a [i]=a[n-1-i];a [n-1-i]=t;}}int main ( ){int x[]={6,7,8,9};f(x,4);for (int i=0;i<4;i++)cout<<x[i];cout<<end1;return 0;}

( 28 )阅读下面程序1 public class Try extends Thread{2 public static void main(String args[ ]){3 Try t = new Try( );4 t.start( );5 }67 public void run( int j){8 int i = 0;9 while(i5){10 System.out.println(" 祝你成功! ");11 i++;12 }13 }14 }该程序要求打印 5 行 “ 祝你成功! ” ,必须改正程序中的某行代码,程序才能完成。选择正确的修改是A )将第 1 行的 extends Thread 改为 implements RunnableB )将第 3 行的 new Try() 改为 new Thread()C )将第 4 行 t.start() 改为 start(t)D )将第 7 行的 public void run( int j) 改为 public void run()

下面程序的输出结果为【】。 include main() { char a[]="morning",t; int i,j=0; for( 下面程序的输出结果为【 】。include<iostream.h>main(){char a[]="morning",t;int i,j=0;for(i=1;i<7;i++)if(a[j]<a[i])j=i;t=a[j];a[j]=a[7];a[7]=a[j];cout<<a;}

阅读以下说明和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 using namespace std; template T min(T x,T y) {i 若有以下程序:include <iostream>using namespace std;template <class T>T min(T x,T y){if(x<y)return x;elsereturn y;}int main(){int n1=2,n2=10;double d1=1.5;d2=5.6;cout<<min(n1,n2)<<",";cout<<min(d2,d2)<<end1;return 0;}程序运行后的输出结果是【 】。

使用VC6打开考生文件夹下的工程test37_1,此工程包含一个源程序文件test37_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:0149 16 25 36 49 64 81源程序文件test37_1.cpp清单如下:include<iostream.h>template <class T, int N = 100> class Vector{T vec[N];public:void set(int pos, T val);T get(iht pos);/***************** found *****************/}template <class T, int N> void Vector<T, N>::set(int pos, T val){vec[pos] = val;}/***************** found *****************/template <class T, int N> Vector<T, N>::get(int pos){return vec[pos];}int main (){Vector<double, 10> v;int i = 0;double d = 0.0;for (i = 0; i < 10; i++)v.set(i, double(i * i));for (i = 0; i < 10; i++)cout<<v.get(i)<<" ";cout<<end1;/***************** found *****************/}

以下程序的输出结果是includevoid reverse(int a[],int n){ int i ,t; for(i=0; 以下程序的输出结果是 #include<iostream.h> void reverse(int a[],int n) { int i ,t; for(i=0;<n/2;i++) { t=a[i]=a[i] =a[n-1-i];a[n-1-i]=t;} } void main() { int b[10]={1,2,3,4,5,6,7,8,9,10};int i,s=0; reverse(b,8); for(i=6;i<10;i++)s+=b[i]; cout<<s; }A.22B.10C.34D.30

有以下程序: void fun(int a*a,int i,int i) {int t; if(i<j); {t=a[i];a[i]=a[j];a[j]=t; fun(a,++i,--j); } } main() {inta[]={1,2,3,4,5,6},i; fun(a,0,5); for(i=0;i(6;i++) cout<(a[i]; } 执行后输出结果是( )。A.6 5 4 3 2 1B.4 3 2 1 5 6C.4 5 6 1 2 3D.1 2 3 4 5 6

下列程序的输出结果是______。 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;}

以下程序的输出结果是includevoid reverse(int a [ ] ,int n){int i,t;for(i=0;i 以下程序的输出结果是 #include<iostream.h> void reverse(int a [ ] ,int n) {int i,t; for(i=0;i<n/2;i++) {t=a[i];a[i]=a[n-1-i];a[n-1-i]=t;} } void main( ) {int b[10]={1,2,3,4,5,6,7,8,9,10};int i,s=0; reverse(b,8); for(i=6;i<10;i++)s+=b[i]; cout << S; }A.22B.10C.34D.30

下面程序的输出结果是 public class Test{ public static void main(String[] args){ int[]array={2,4,6,8,10}; int size=6; int result=-1: try{ for(int i=0;i<sizeresult==-1;i++) if(array[i]==20)result=i; }catch(ArithmeticException e){ System.out.println("Catch---1"); }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Catch---2"); }catch(Exception e){ System.out.println("Catch---3"); } } }A.Catch---1B.Catch一--2C.Catch---3D.以下都不对

以下程序的输出结果是 include void reverse(int a[ ] ,int n) { int i,t;for(i=0 以下程序的输出结果是#include<iostream.h>void reverse(int a[ ] ,int n){ int i,t;for(i=0;i<n/2;i++){t=a[i] ;a[i] =a[n-1-i] ;a[n-1-i] =t;}}void main( ){ int b[10] ={1,2,3,4,5,6,7,8,9,10};int i,s=0;reverse(b,8) ;for(i=6;i<10;i++) s+=b[i] ;cout < < S;}A.22B.10C.34D.30

以下程序的输出结果是()。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

有以下程序void fun(int* a, int i, int j){ int t; if(i<j); { t =a[i] ;a[i]= a[j] ;a[i]= t; fun(a, ++i, --j);}}main(){ int a[i]={1,2,3,4,5,6}, i; fun(a,0,5); for(i=0;i<6; i++) cout<<a[i];}执行后输出结果是A.654321B.432156C.456123D.123456

以下程序的输出结果是()。//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

有以下程序:include using namespace std;void fun(int i,int j){ cout 有以下程序: #include <iostream> using namespace std; void fun(int i,int j) { cout<<(i+j)<<end1; } void fun(int i) { cout<<i++<<end1; } int main() { int a=1; fun(A) ; return 0; } 该程序执行后的输出结果是( )。A.1B.2C.3D.4

有以下程序void fun(intā*a,int i,int i){ int t;if(i<j);{ t=a[i];a[i]=a[j];a[j]=t;fun(a,++i,- -j);}}main( ){ int a[]={1,2,3,4,5,6},i;fun(a,0,5);for(i=0;i<6;i++)cout<<a[i];}执行后输出结果是A.6 5 4 3 2 1B.4 3 2 1 5 6C.4 5 6 1 2 3D.1 2 3 4 5 6

下列程序的输出结果是( )。 Public class Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;isizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对

下列程序的输出结果是( )。 public class Test{ public static void main(String[]args){ int[]array=(2,4,6,8,lO); int size=6; int result =-1: try{ for(int i=0;i(size 8Lresult= = -1;) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch- - -l"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch- - -2"); } catch(Exception e){ System.out.println("Catch- - -3");) } }A.Catch- - -1B.Catch- - -2C.Catch- - -3D.以上都不对

( 17 )下列程序的输出结果是public class Test{public static void main(String[] args){int [] array={2,4,6,8,10};int size=6;int result=-1;try{for{int i=0;isize result==-1;i++}if(array[i]==20) result=i;}catch(ArithmeticException e){System.out.println( " Catch---1 " );catch(ArrayIndexOutOfBoundsException e){System.out.println( " Catch---2 " );catch(Exception e){System.out.println( " Catch---3 " );}}A ) Catch---1B ) Catch---2C ) Catch---3D )以上都不对

对于下列代码段,执行后输出结果是()。 int n,m; int[] a=new int[5]; n=10; m=10; try{ for(inti=0;i=a.Length;i++); a[i]=i; n=1/(n-m); } catch(DivideByZeroExceptione1){ Console.WriteLine(“产生零除异常!”); } catch(IndexOutOfRangeExceptione2) { Console.WriteLine(“产生数组访问越界异常!”); }

研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。       A、10  数组越界  程序结束B、10   程序结束C、数组越界  程序结束D、程序结束

Which the statement is true?()A、 The Error class is a Runtime Exception.B、 No exceptions are subclasses of Error.C、 Any statement that may throw an Error must be enclosed in a try block.D、 any statement that may throw an Exception must be enclosed in a try block.E、 Any statement that may throw an Runtime Exception must be enclosed in a try block.

单选题1. class A implements Runnable (  2. int i;  3. public void run ( ) (  4. try (  5. thread.sleep(5000);  6. i= 10;  7. ) catch(InterruptedException e) {}  8. )  9. )  10.    11. public class Test {  12. public static void  main (string args[]) ( 13. try (  14. A a = new A ( );  15. Thread t = new Thread (a);  16. t.start( );  17.    18. int j= a.i;  19.    20. ) catch (Exception e) {}  21. )  22. }   Which statement al line 17 will ensure that j=10 at line 19?()A a.wait();B t.wait();C t.join();D t.yield();E t.notify();F a.notify();G t.interrupt();

问答题对于下列代码段,执行后输出结果是()。 int n,m; int[] a=new int[5]; n=10; m=10; try{ for(inti=0;i=a.Length;i++); a[i]=i; n=1/(n-m); } catch(DivideByZeroExceptione1){ Console.WriteLine(“产生零除异常!”); } catch(IndexOutOfRangeExceptione2) { Console.WriteLine(“产生数组访问越界异常!”); }