分析并写出下列程序的运行结果。
请帮忙给出正确答案和分析,谢谢!
请帮忙给出正确答案和分析,谢谢!
第1题
阅读下列程序并写出程序运行结果。
Public Sub change1(ByVal x As Integer, ByVal y As Integer)
Dim t As Integer
t = x
x = y
y = t
End Sub
Public Sub change2(x As Integer, y As Integer)
Dim t As Integer
t = x
x = y
y = t
End Sub
Private Sub Form_Click()
Dim a As Integer, b As Integer
a = 22: b = 33
change1 a, b
Form1.Print "A1="; a, "B1="; b
a = 22: b = 33
change2 a, b
Form1.Print "A2="; a, "B2="; b
End Sub
写出程序运行时,单击窗体Form1上的输出结果。
第3题
阅读下列程序,请写出程序的运行结果。
public class C
{
public static void main(String[] args)
{
String text="public static void main(String[] args)";
int theCount=0;
int index=-1;
String theStr="i";
index=text.indexOf(theStr);
while(index>=0)
{
++theCount;
index+=theStr.length();
index=text.indexOf(theStr,index);
}
System.out.println("The Text contains"+theCount+"i");
}
}
第4题
写出下列程序的运行结果。
#include void Fun(){int num=20;cout<< "The Fun's num is"<< num<< endl;
}void main(){int num=10;cout<< "The main's num is "<< num<< endl;Fun();{int num=30;
cout<< "The Field's num is "<< num<< endl;}cout<< "The main's num is "<< num<< endl;}
第6题
public class Class1
{
public static void main(String args[])
{
int n=6,sum=0;
for(int k=1;k<=n;k++)
{
if (n%k==0)
sum+=k;
}
System.out.println(sum);
}
}
第8题
阅读下列程序,请写出该程序的输出结果。
public class C
{
int x=10;
static int y=20;
public static void main(String[] args)
{
C obj1=newC();
C obj2=newC();
obj1.x*=2;
obj1.y*=3;
obj2.x+=4;
obj2.y+=5;
System.out.println(obj1.x);
System.out.println(obj1.y);
System.out.println(obj2.x);
System.out.println(obj2.y);
}
}
第9题
写出下列程序段的输出结果。(假设此栈中元素的类型是char)
voide main()
{stack s;
char x,y;
InitStack(s)
x=‘1’,y=‘0’
push(s,x);
push(s,x);
push(s,y);
push(s,x);
push(s,‘e’);
push(s,x);
pop(s,x);
push(s,‘h’);
while(!stackEmpty(s))
{pop(s,y);
printf(y);
}
prinft(x)
}
第10题
课程(最多为5门)的成绩.然后计算片打印每个学生各门课的总分和平均分。其中,m和n的值由用户从键盘输入。