以下代码运行后,result的值为() var result = 0; for (var i = 1; i <= 10; i++) { result = result * i }
A.0
B.1
C.9的阶乘
D.10的阶乘
第1题:
A.6
B.7
C.10
D.11
E.Compilation fails.
F.Anexception is thrown at runtime.
第2题:
下面程序的运行结果是( )。 #include<iostream.h> intfun(inta[],int n) { int result=1; for(int i=“i<n;i++) result’resultxa[i]; return result; } void main() { inta[3]={3,4,5}; cout<<fun(a,3)<<endl; }
A.12
B.15
C.20
D.60
第3题:
下面程序的输出结果是 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<size&&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---1
B.Catch一--2
C.Catch---3
D.以下都不对
第4题:
阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。
【说明】
本程序的功能是实现任意两个大整数的乘法运算,例如:
输入整数1:8934793850094505800243958034985058
输入整数2:234584950989689084095803583095820923
二者之积:
209596817742739508050978890737675662366433464256830959194834854876 8534
【C++代码】
include<iostream.h>
const int MAXINPUTBIT=100;
const int MAXRESULTBIT=500;
class LargeNumber{
int i,j;
int temp;
int one[MAXINPUTBIT+1];
int onebit; //one的位数
int two[MAXINPUTBIT+1];
int twobit; //two的位数
int result[MAXRESULTBIT+1];
public:
LargeNumber();
~LargeNumber();
int inputone(); //出错返叫0,否则返回1
int inputtwo(); //同上
void multiplication(); //乘
void clearresult(); //清零
void showresult(); //显示
};
LargeNumber∷LargeNumber()
{
for(i=0;i<=MAXINPUTBIT;i++)
{
one[i]=0;
two[i]=0;
}
nebit=0;
twobit=0;
inputone();
inputtwo();
}
LargeNumber∷~LargeNumber()
{
}
int LargeNumber∷inputone()
{
char Number[MAXINPUTBIT+1];
cout<<"Please enter one:";
cin>>Number;
i=0;
j=MAXINPUTBIT;
while(Number[i]!='\0')
i++;
nebit=i;
for(i--;i>=0;i--,j--)
{
if(int(Number[i])>=48&&int(Number[i])<=57)
(1); //由字符转换为数字
else
return 0;
}
return 1;
}
int LargeNumber∷inputtwo()
{
char Number[MAXINPUTBIT+1];
cout<<"Please enter two:";
cin>>Number;
i=0;
j=MAXINPUTBIT;
while(Number[i]!='\0')
i++;
twobit=i;
for(i--;i>=0;i--,j--)
{
if(int(Number[i])>=48&&int(Number[i])<=57)
two[j]=int(Number[i]-48); //由字符转换为数字
else
return 0;
}
return 1;
}
void LargeNumber∷multiplication() //乘法
{
clearresult();
int m;
for(i=MAXINPUTBIT;i>=0;i--)
{
temp=two[i];
for(j=(2),m=MAXINPUTBIT;m>=0;m--,j--)
{
result[j]+=temp*one[m];
if(result[j]>9)
{
result[j-1]+=result[j]/10;
(3);
}
}
&n
第5题:
下面程序的运行结果是( )。 #include<iostream.h> intfun(inta[],intn) { intresult=1; for(inti=1;i(n;i++) result=result*a[i]; returnresult; } voidmain( ) { inta[3]={3,4,5); coHt<<fun(a,3)<<endl; }
A.12
B.15
C.20
D.60
第6题:
若有以下窗体单击事件过程:Private SubForm_Click( ) result=1 For i=1To 6 Step 3 result=result*i Next i MsgBoxresult End Sub打开窗体运行后,单击窗体,则消息框的输出内容是( )。
A.1
B.4
C.15
D.120
第7题:
在窗体中使用一个文本框(名为n)接受输入的值,有一个命令按钮run,事件代码如下; Ptivate Sub run_Click() Yesult=" " For i=1 To Me!n For j=1 To Me!n result=result +"*" Next j result=resuh+Chr(13)+Chr(10) NexL i MsSBOx result End Sub 打开窗体后,如果通过文本框输入的值为4,单击命令按钮后输出的图型是
A. * * * * * * * * * * * * * * * *
B. * * * * * * * * * * * * * * * *
C. * * * * * * * * * * * * * * * * * * * * * * * * * * * *
D. * * * * * * * * * * * * * * * *
第8题:
试题31
若有以下窗体事件过程:
Private Sub Form_Click()
result=1
For i=1 To 6 step 3
Result = result * 1
Next i
MsgBox result
End Sub
打开窗体运行后,单击窗体,则消息框的输出内容是()
A.1
B.4
C.15
D.120
第9题:
以下代码的输出结果是() while(1) { $var++; $result=$var; if($result==17)break; $var--; } echo($result);
第10题:
public static void main(String[]args){ for(inti=0;i<=10;i++){ if(i>6)break; } System.out.println(i); } What is the result?()
第11题:
public static void main(String[] args) { for (int i=0;i<= 10;i++){ if( i>6) break; } System.out.println(i); } What is the result?()
第12题:
The code will deadlock.
The code may run with no output.
An exception is thrown at runtime.
The code may run with output “0 6”.
The code may run with output “2 0 6 4‟.
The code may ruin with output “0 2 4 6”.
第13题:
下面程序的运行结果是( )。 #include<iostream.h> int fun(int a[],int n) { int resuh=1; for(inl i=1;i<11;1‘++) result=result * a[i]; retum result; } void main int a[3]={3,4,5}: cout<<fun(a,3)<<endl: }
A.12
B.15
C.20
D.60
第14题:
假定a=3,下列程序的运行结果是( )。 #inelude<iostream.h> int fun(int n); void main() { cout<<"Please input a number:"; int a,result=0; cin>>a; result=fun(a); tout<<result<<end1; } intfun(int n) { int p=1,result=0; for(int i=1;i<=n;i++) { p*=i; result+=p; } return result; )
A.4
B.8
C.9
D.20
第15题:
若有以下窗体单击事件过程:
Private Sub Form_Click()
result=1
For i=1 To 6 step 3
result=result*i
Next i
MsgBox result
End Sub
打开窗体运行后,单击窗体,则消息框的输出内容是
A.1
B.4
C.15
D.120
第16题:
下列程序的功能是:输入10个整数,逆序后输出。请在程序空白处填入适当语句使程序完成指定的功能。
Private Sub Command2_Click()
Dim i, j, k,temp, arr(11) As lnteger
Dim result As String
For k=1 To 10
arr(k) =Val (InputBox( "请输入第" & k & "个数:","数据输入窗口"))
Next k
i=1
j = 10
Do
temp=arr(i)
arr(i)=arr(j)
arr(j)=temp
i=i+1
j=【12】
Loop While【13】
result =""
For k=1 To 10
result=result & arr(k) & Chr(13)
NeXt k
MsgBox result
End Sub
第17题:
在窗体中使用一个文本框名为n.接受输入的值,有一个命令按钮run,事件代码如下: Private Sub run_Click( ) result = "" For i = 1 To Me!n For j = 1 To Me!n result = result + "*" Next j result = result + Chr(13) + Chr(10) Next i MsgBox result End Sub 打开窗体后,如果通过文本框输入的值为4,单击命令按钮后输出的图型是
A. * * * * * * * * * * * * * * * *
B. * * * * * * * * * * * * * * * *
C. * * * * * * * * * * * * * * * * * * * * * * * * * * * *
D. * * * * * * * * * * * * * * * *
第18题:
下面程序的运行结果是 #include<iostream.h> int fun(inta[],int n) { int result=1; for(int i=1:i<n;i++) result=result*a[i]; remm result; } void main() { int a[3]={3,4,5}; cout <<fun(a,3) <<end1; }
A.12
B.15
C.20
D.60
第19题:
若有以下窗体单击事件过程:Private SubForm_Click( )
result=1
For i=1To 6 Step 3
result=result*i
Next i
MsgBoxresult
End Sub打开窗体运行后,单击窗体,则消息框的输出内容是( )。
A.1
B.4
C.15
D.120
第20题:
( 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;i<size && 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---1
B ) Catch---2
C ) Catch---3
D )以上都不对
答案暂缺
第21题:
int i = 0, j = 5; tp; for (;;) { i++; for(;;) { if (i> --j) { break tp; break tp; } } System.out.println(“i=” +i “,j =”+j); } What is the result?()
第22题:
int i = 0, j = 1; if ((i++ == 1) && (j++ == 2)) { i = 42; } System.out.println(“i = “ + i + “, j = “ + j); What is the result?()
第23题:
0
17
18
这是一个无限循环,没有输出
第24题:
i = 1, j = 2
i = 1, j = 1
i = 42, j = 2
i = 42, j = 1
Compilation fails.