以下程序的输出结果是【 】。 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]
举一反三
- using System; class Test { public static void Main () { int[ ] a ={2,4,6,8,10,12,14,16,18}; for (int i=0; i<9; i++) { Console.write(“ ”+a[i]); if ((i+1)%3==0) Console.writeLine(); } } }[/i]
- 下面代码的运行结果是_____________。 public class Test{ public static void main(String[] args){ int[] a=new int[3]; int[] b= new int[]{1,2,3,4,5}; a=b; for(int i=0; i<b.length; i++){ System.out.print(a[i]+" "); } } }[/i]
- 设int[] array=new int[5]{11,12,13,14,15};以下语句不能实现数组元素输出的是( ) A: foreach( int i in array){ Console.Write(i+ );} B: for( int i=0;iarray.Length();i++){ Console.Write(array[i]+ );} C: for( int i=0;iarray.GetLength(0);i++){ Console.Write(array[i]+ );} D: for( int i=0;iarray.Length;i++){ Console.Write(array[i]+ );}
- #include [stdio.h]int main() { int a[3][3],i,j; for(i=0;i<3;i++) for(j=0;j<3;j++) a[i][j]=3*i+j; for(i=0;i<3;i++) printf("%d ",a[i][1]); return 0;}[/i][/i]
- 下面代码的运行结果是。 public class Test { public static void main(System[] args){ int[ ] a ={10,20,30}; int[ ] b ={1,2,3,4,5}; a=b; for (int i=0;i<a.length;i++){ System.out.print(a[i]+” ”); } } }[/i]