对于下列代码段,执行后输出结果是()。intn,m;int[]a=newint[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(“产生数组访问越界异常!”);}[/i]
举一反三
- 下列代码段中试图用try-catch-catch结构捕获和处理异常,其中有的地方是错误的,请将错误的地方纠正过来。 int m;int[] a=new int[5]; n=10; m=10; try { m=int.Parse(“2000$”);for(int i=0; i<=a.Length; i++) a[i]=i; } catch(Exception e1) { Console.WriteLine("产生异常:{0}",e1.Message); } catch(IndexOutOfRangeException e2) { Console.WriteLine("产生异常:{0}",e2.Message); }[/i]
- 请写出输出结果______ ______ main ( ) { int a[5]={15, 23, 4, 67, 98}; int i, m, n; m=n=a[0]; for (i=1; i<5; i++ ) {if (m>a[ i ] ) m=a[ i ]; if (n
- 以下程序的输出结果是【 】。 class Program { public static void Main(string[] args) { int[] a = new int[3] { 1, 2, 3 }; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); int[] b = a; for (int i = 0; i < 3; i++) b[i] = 2 * b[i]; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); Console.Read(); } }[/i][/i][/i][/i]
- 有以下程序: prt[int *m,int n) int i; for(i=0;i<n;i++) m[i]++; main() int a[]=1,2,3,4,5,i; prt(a,5); for(i=0;i<5;i++) printf("%d,",a[i]); 程序运行后输出结果是______。[/i][/i]
- 下列程序输出结果是:() int i,j,m,n; m=n=0; for(i=0;i<2;i++) for(j=0;j<2;j++) if(j>=i)m=1;n++; printf("n=%d ",n);