有人编写了如下程序: Private Sub Form. Click( ) Dim s As Integer,x As Integer s=0 x=0 Do While S=1000 x=x+l s=s+x^2 Loop Print s End Sub 上述程序的功能是:计算s=1+22+32+…+n2+…,直到s>10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是( )。
A.把x=0改为x=1.
B.把Do While s=10000改为Do While s<=10000
C.把Do While S=10000改为Do While s>10000
D.交换x=x+1和s=s+x^2的位置
第1题:
现有如下程序: Private Sub Command1_Click() s=0 For i=1 To 5 s=s+f(5+i) Next Print s End Sub Public Function f(x As Integer) If x>=10 Then t=x+1 Else t=x+2 End If f=t End Function 运行程序,则窗体上显示的是( )。
A.38
B.49
C.61
D.70
第2题:
有以下程序 #include <iostream> using namespace std; class sample { private: int x; public: sample(int a) { x=a; } friend double square(sample s); }; double square(sample s) { return s.x*s.x; } int main() { sample s1 (20),s2(30); cout<<square(s2)<<end1; return 0; } 执行结果是
A.20
B.30
C.900
D.400
第3题:
11、下面哪些定义是类型正确的?
A.f :: (Integer, Integer) -> Float f (x,y) = x / y
B.f :: (Integer, Integer) -> Float f (x,y) = (fromInteger x) / (fromInteger y)
C.f :: (Integer, Integer) -> Float f (x,y) = 3*x + y
D.f :: (Integer, Integer) -> Integer f (x, y) = 3*x + y
第4题:
有如下程序: #inClude<iostream> using namespaCe std; Class Sample{ friend long fun(Sample S); publiC: Sample(10ng A.{x=a;} private: long X; }; long fun(Sample S){ if(S.x<2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} Cout<<sum: return 0; } 执行这个程序的输出结果是( )。
A.120
B.16
C.154
D.34
第5题:
有人编写了如下程序:
Private Sub Form. Click( )
Dim s As Integer,x As Integer
s=0
x=0
Do While S=1000
x=x+l
s=s+x^2
Loop
Print s
End Sub
上述程序的功能是:计算s=1+22+32+…+n2+…,直到s>10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是( )。
A.把x=0改为x=1.
B.把Do While s=10000改为Do While s<=10000
C.do="" while="" s="">10000
D.交换x=x+1和s=s+x^2的位置