6、在C#中,下列代码运行结果是()。 class A { static void Main() { int[] num=new int[]{1,3,5}; ArrayList arr = new ArrayList(); for (int i = 0; i < num.Length; i++) { arr.Insert(i,num[i]); } arr.Insert(1, 4); Console.Write(arr[2]); } }
6、在C#中,下列代码运行结果是()。 class A { static void Main() { int[] num=new int[]{1,3,5}; ArrayList arr = new ArrayList(); for (int i = 0; i < num.Length; i++) { arr.Insert(i,num[i]); } arr.Insert(1, 4); Console.Write(arr[2]); } }
参考答案和解析
3
相关考题:
下面程序的运行结果为【 】。class A} public:int num;A(int i){num=i;}A(A a){num=++a.num;}void print(){cout<<num;}};void main(){A a(1),b(a);a.print();b.print();}
下面程序的输出是【 】。main(){int arr[10],i,k=0;for(i=0;i<10;i++)arr[i]=i;fov(i=1;i<4;i++)k+=arr[i]+i;printf("%d\n",k);}
下面程序的运行结果为includeclass A{int num;public:A(int i){num=i;}A(A a) 下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int i){num=i;} A(A a) { num = a.num+ +;} void print( ) {cout << num;} }; void main( 0 { A a (1),b (a) ; a.print( ); b.A.11B.12C.21D.22
数组arr经过下面的操作后结果为( )。 int[] arr={1, 2, 3}; for (int i=0; i < 2; i++) arr[i] = 0;A.arr[0]==0B.arr[0]==1C.arr[1]==1D.arr[2]==0
下面程序的运行结果为 include class A {int num; public: A(int) {num=i;} A(A public:A(int) {num=i;}A(A a) {hum=a. num++;}void print( ) {cout < < num;}};void main( ){A a(1) ,b(a) ;a. print( ) ;b. print( ) ;}A.11B.12C.21D.22
下面程序段的输出结果是( )。 public class Test {public static void main(String args[]){ int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i= 1 ; i<= 10;i++) a[i]=i; for(int i=1 ; i<=3;i++) p[i]=a[i*i]; for(int i= 1 ;i<=3;i++) k=k+p[i]*2; System.out.println(k); }}A.37B.31C.33D.35
若有以下程序: include using namespace std; class sample { int x; public: sample 若有以下程序:include <iostream>using namespace std;class sample{int x;public:sample(){}void setx(int i){x=i;}friend iht fun(sample B[],int n){int m=0;for{int i=0;i<n;i++)if(B[i].x>m)m=B[i].x;return.m;}};int main ( ){sample A[10];int arr[]={90,87,42,78,97,84,60,55,78,65};for(int i=O;i<10;i++)A[i].setx(arr[i]);cout<<fun(A, 10)<<end1;return 0;}该程序运行后的输出结果是【 】。
顺序执行下面的语句后,输出的结果是______。public class exl6{public static void main(String[] args){int i;int a[] = new int[10];for(i = O; i < a.length; i++)a[i] = i * 10 + j;for(i = 1; i < a.length; i++)if(a[i]%5 == O)System,out.println(a[i]);}}
下面程序段的输出结果是 public class Test { public static void main(String args[]){ int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=l;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }A.37B.31C.33D.35
下面程序的运行结果为()。includeclass A{int numpublic:A(int i){num=i;}A(Aa 下面程序的运行结果为( )。 #include<iostream.h> class A { int num public: A(int i){num=i;} A(Aa){Bum=a.num++;} void print(){cout<<Bum;} }; void main() { A a(1),b(a); A. print(); B.print(); }A.11B.12C.21D.22
若有以下程序:includeusing namespace std;class sample{private: int x;public: sam 若有以下程序: #include <iostream> using namespace std; class sample { private: int x; public: sample() { } void setx(int i) { x=i; } friend int fun(sample B[],int n) { int m=O; for (int i=O; i<n; i++) { if(B[i].x>m) m=B [i].x; } return m; } }; int main ( ) { sample A[10]; int arr[]={90,87,42,78,97,84,60,55,78,65}; for (int i=O;i<10;i++) A[i]. setx (arr[i]); cout<<fun(A, 10)<<end1; return 0; } 该程序运行后的输出结果是( )。A.97B.84C.90D.78
阅读以下说明和Java代码,回答问题1和问题2,将解答填写在对应栏内。【Java代码】class usethread implements (1) {int numusethread(int n){num=n;}public void (2) {for(int i=0;i<3;i++)System.out.println("running:"+num);System.out.println("finished:"+num);}public class multhread{public static void main(String args[]) (3) InterruptedException{Thread m1=new Thread(new usethread(1));Thread m2=new Thread(new usethread(2));m1.start();m2.start();m1.join();m2.join();}}【问题1】补充完整上面Java代码中(n)处。【问题2】写出上面Java代码运行的结果。
有如下程序:include using namespace std;int getSum(int num);int main (){ int i; 有如下程序: #include <iostream> using namespace std; int getSum(int num); int main () { int i; for (i=1; i<4; i++) cout<<getSum(i); return 0; } int getSum(int hum) { static int sum=O; sum+=num; return sum; } 上述程序执行后的输出结果是( )。A.136B.248C.123D.135
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出
下面代码的运行结果是 public class Test{ public static void main(String args[]){ for(int i=0; i<3;i++){ if(i<2) continue; System.out.println(i); } } }A.0B.1C.2D.3
下面程序的输出是main(){ int arr[10],i,k=0; for(i=0;i10;i++) arr[i]=i; for(i=1;i4;i++) k+=arr[i]+i; printf("%d\n",k);}
下面程序的输出是【 】。main(){int arr[10],i,k=0;for(i=0;i<10;i++)arr[i]=i;for(i=1;i<4;i++)k+=arr[i]+i;printf("%d\n",k);}
下列程序用于打印出ASCⅡ字符,其析构函数内的语句应为【 】。 include inelude 下列程序用于打印出ASCⅡ字符,其析构函数内的语句应为【 】。include<iostream. h>inelude<iomanip, h>template<class T>class Array{T * elems;int size;public:Array(int.s);~Array()T operator[](int)void perator=(T)};template<class T>Array<T>::Array(int s)size=s;elems=new T[size]for(int i=0;i<size;i++)elems[i]=0}template<celass T>Array<T>::~Array(){______template <class T>T Array<T>::operator[](int index){return elems[index];}template<class T>void Array<T>::operator=(T temp){for(int i=0;i<size;i++)elems[i]=temp;}void main(){int i,n=26;Array<int> arr1(n)Array<char> arr2(n)for(i=0;i<n;i++){ -.arr1[i]='a'+i;arr2[i]='a'+i;}cout<<"ASCII 字符"<<endl;for(i=0;i<n;i++)cout<<setw(8)<<arr1[i]<<setw(8)<<arr2[i]<<endl;}
4 . 写出程序的输出结果class Class1 {private string str = "Class1.str";private int i = 0;static void StringConvert(string str) {str = "string being converted.";}static void StringConvert(Class1 c) {c.str = "string being converted.";}static void Add(int i) {i++;}static void AddWithRef(ref int i) {i++;}static void Main() {int i1 = 10;int i2 = 20;string str = "str";Class1 c = new Class1();Add(i1);AddWithRef(ref i2);Add(c.i);StringConvert(str);StringConvert(c);Console.WriteLine(i1);Console.WriteLine(i2);Console.WriteLine(c.i);Console.WriteLine(str);Console.WriteLine(c.str);}}
以下程序的输出结果是 ______。includeInt f(){static int i=0;int a=1;a+=;i++;ret 以下程序的输出结果是 ______。 #include<iostream.h> Int f(){ static int i=0; int a=1; a+=; i++; return a; } void main() { int i,s=0; for(i=0;i<4;i++) s+=f(); cout<<s;A.10B.15C.21D.28
下面程序段的输出结果是( )。 public class TeSt{ public static voidmain(Stringargs[]){ int[]a=new int[11]; int[]p=new int[4]; intk=5; for(int i=1;i<=10;i++) a[i]=i; for(inti=1;i<=3;i++) p[i]=a[i*i]; for(inti=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }A.37B.31C.33D.35
下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.
下面程序段的输出结果是( )。 public class Test( public static void main(String args[]){ int[]a=new int[113; int[]p=new int[43; int k=5: for(int i=1;i=10;i++) a[i]=i; for(int i=1;i=3;i++) p[i]=a[i*i]; for(int i=1;i=3;i++) k=k+p[i]*2; System.out.println(k); } }A.37B.31C.33D.35
本题中数组arr中存储了学生的成绩,分别为87,45,56,78,67,56,91,62,82,63,程序的功能是计算低于平均分的人数,并打印输出结果。请在程序空缺部分填写适当内容。使程序能正确运行。public class javal{public static void main(String[]args){int arr[]={56,91,78,67,56,87,45,62,82,63};int num=arr.lengthint i=0;int sumScore= 0;int sumNum=0;double average;while(i<;num){sumScore=sumScore+arr[i];;}average= ;i=0;do{if(arr[i]<;average)sumNum++:i++;}while( );System.OUt.println("average:"+average+",be-lows average:"+sumNum);}}
本题的功能是用冒泡法对数组元素arr[]={30,1,-9,70)进行从小到大排列。冒泡法排序是比较相邻的两个元素的大小,然后把小的元素交换到前面。public class javal{public static void main(String[]args){int i,j;int arr[]={30,1,-9,70);int n= ;for(i=0;i<;n-1;i++){for(j=i+1;j<;n;j++){if(arr[i]>;arr[j]){int temp=arr[i];;;}}}for(i=0;i<;n;i++)System.out.print(arr[i]+"");}}
下列代码的执行结果是 public class Test{ public int aMethod( ) { static int i=0; i+ +; System.out.println(i); } public static void main(String args[ ]){ Test test = new Test( ); test.aMethod( ); } }A.编译错误B.0C.1D.运行成功,但不输出
下列程序的输出结果是______。 include int CalcDigital(char*str) { if(str= =NULL) 下列程序的输出结果是______。include<iostream.h>int CalcDigital(char*str){if(str= =NULL)return 0;int num_of_digital=0;for(int i=0;str{i]!=0x0;i++)if(str[i]<='9' str[i]>='0')num_of_digital++;return num_of_digital;}void main( ){char a[]="Beijing20080lympic";cout<<CalcDigital(a)<<endl;}
单选题class Computation extends Thread { private int num; private boolean isComplete; private int result; public Computation(int num) { this.num = num; } public synchronized void run() { result = num * 2; isComplete = true; notify(); } public synchronized int getResult() { while (!isComplete) { try { wait(); } catch (InterruptedException e) { } } return result; } public static void main(String[] args) { Computation[] computations = new Computation [4]; for (int i = 0; i computations.length; i++) { computations[i] = new Computation(i); computations[i] .start(); } for (Computation c : computations) System.out.print(c.getResult() +“ “); } } What is the result?()A The code will deadlock.B The code may run with no output.C An exception is thrown at runtime.D The code may run with output “0 6”.E The code may run with output “2 0 6 4‟.F The code may ruin with output “0 2 4 6”.