网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

有人编写了如下程序: 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的位置


参考答案

更多 “ 有人编写了如下程序: 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+…,直到s10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是( )。A.把x=0改为x=1.B.把Do While s=10000改为Do While s=10000C.把Do While S=10000改为Do While s10000D.交换x=x+1和s=s+x^2的位置 ” 相关考题
考题 ( 35 )有如下程序::#includeusing namespace std:class Sample{friend long fun ( Sample s ) ;public:Sample ( long a ) {x=a;}Private:long x;};long fun ( Sample s ){if ( s.x2 ) retum 1;retum s.x*fun ( Sample ( s.x-a ))}int main (){int sum=0for ( int i =0; i 6; i ++ ) { sum+=fun ( Sample ( i ) ; ) }coutSUM;retum 0;}运行时输出的结果是A ) 120B ) 16C ) 154D ) 34

考题 有人编写了如下程序:Private Sub Form_Click()Dim s As Integer,x As Integers=0x=0Do While s=10000x=x+1s=s+x^2LoopPdnt sEnd Sub上述程序的功能是:计算s=1+22+32+…+n2+…,直到s10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是A.把x=0改为x=1B.把Do While s=10000改为Do While s=10000C.把Do While s=10000改为Do While s10000D.交换x=x+l和s=s+x^2的位置

考题 有如下程序: include using namespace std; class Sample { frien 有如下程序: #include <iostream> using namespace std; class Sample { friend long fun(Sample s); public: Sample(long a) {x=a;} private: long x; }; long fun(Sample s) { if(s.x < 2) return 1; return s.x * fun(Sample(s.x-1)); } int main() { int stun = 0; for (int i=0; i<6; i++) {sum += fun(Sample(i));} cout << sum; return 0; }运行时输出的结果是A.120B.16C.154D.34

考题 下列程序中,实现将封装数据类型Integer和基本数据类型int之间的转换,以及Integer,int类型和String类型之间的转换。请将程序补充完整。程序运行结果如下:123456456public class ex7_1{public static void main(String[]args) {Integer intObj;int n;String s;intObj = new Integer(123);n=intObj.__________;System.out.printin(Integer.toString(n));s=new String("456");intObj=Integer._________;System.out.println(intObj.__________);n=Integer.parseInt(s);System.out.println(Integer.toString(n));}}

考题 现有如下程序: 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.38B.49C.61D.70

考题 有如下程序: #inCludeiostream 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.x2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i6;i++) {sum+=fun(Sample(i));} Coutsum: return 0; } 执行这个程序的输出结果是( )。A.120B.16C.154D.34

考题 有以下程序include using namespace std; class sample { private: int x; public: 有以下程序 #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.20B.30C.900D.400

考题 有人编写了如下程序:Private Sub Form. Click( )Dim s As Integer,x As Integers=0x=0Do While S=1000x=x+ls=s+x^2LoopPrint sEnd Sub上述程序的功能是:计算s=1+22+32+…+n2+…,直到s10000为止。程序运行后,发现得不到正确的结果,必须进行修改。下列修改中正确的是( )。A.把x=0改为x=1.B.把Do While s=10000改为Do While s=10000C.do= while= s=10000D.交换x=x+1和s=s+x^2的位置

考题 11、下面哪些定义是类型正确的?A.f :: (Integer, Integer) - Float f (x,y) = x / yB.f :: (Integer, Integer) - Float f (x,y) = (fromInteger x) / (fromInteger y)C.f :: (Integer, Integer) - Float f (x,y) = 3*x + yD.f :: (Integer, Integer) - Integer f (x, y) = 3*x + y