写出程序运行结果int sum(int a){auto int c=0;static int b=3;c+=1;b+=2;return(a+b+C);}vo
写出程序运行结果
int sum(int a)
{
auto int c=0;
static int b=3;
c+=1;
b+=2;
return(a+b+C);
}
void main()
{
38
int I;
int a=2;
for(I=0;I<5;I++)
{
printf("%d,", sum(a));
}
}
写出程序运行结果
int sum(int a)
{
auto int c=0;
static int b=3;
c+=1;
b+=2;
return(a+b+C);
}
void main()
{
38
int I;
int a=2;
for(I=0;I<5;I++)
{
printf("%d,", sum(a));
}
}
写出以下程序的运行结果。
#include int fun(int a){int b=0;static int c=3;b ; c ;return(a b c);}
main(){int i, a=5;for (i=0; i<3; i )cout<< i<< " "<< fun(a)<< " ";}
写出以下程序的运行结果。public class Test2 {public static void main(String args[ ]){int i,j;int a[]={17,91,65,35,28};for (i = 0; i < a.length-1; i++ ) {int k = i;for(j = i; j < a.length; j++ )if (a[j]>a[k] )k = j;int temp =a[i];a[i] = a[k];a[k] = temp;}for (i =0; i<a.length; i++ )System.out.print(a[i]+" ");System.out.println();} }
class A
{
int a;
A(int b)
{a=b;}
void show()
{System.out.println(“a=”+a);}
}
public class Class1
{
public static void main (String args[])
{
A bj=new A(12345);
boolean b=false;
char ch=97;
obj.show();
System.out.println(“b=”+b+”/tch=”+ch);
}
}
A.9
B. 6
C. 3
D. 0
public void actionPerformed(ActionEvent e)
{
int sum;
if(e.getSource()==button)
{
String s=text1.getText();
StringTokenizer fenxi=new StringTokenizer(s,",/t/n");
int n=fenxi.countTokens();
double a[]=new double[n];
for(int i=0;i<n;i++)
{
String temp=fenxi.nextToken();
a[i]=Double.valueof(temp).doubleValue();
}
sum=0;
for(int i=0;i<n;i++)
sum+=[i];
text2.setText(""+sum);
}
}
阅读下列程序,请写出程序的运行结果。
import java.applet.*;
import java.awt.*;
public class C extends Applet implements Runnable
{
Thread redBall,blueBall;
Graphics redPen,bluePen;
int blueSeta=0,redSeta=0;
public void init()
{
setSize(250,200);
redBall=new Thread(this);
blueBall=new Thread(this);
redPen=getGraphics();
bluePen=getGraphics();
redPen.setColor(Color.red);
bluePen.setColor(Color.blue);
setBackground(Color.gray);
}
public void start()
{
redBall.start();
blueBall.start();
}
public void run()
{
intx,y;
while(true)
{
if(Thread.currentThread()==redBall)
{//以下代码为顺时针画圆
x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
redPen.setColor(Color.gray);
redPen.fillOval(100+x,100+y,10,10);
redSeta+=3;
if(redSeta>=360)redSeta=0;
x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
redPen.setColor(Color.red);
redPen.fillOval(100+x,100+y,10,10);
try{redBall.sleep(20);}
catch(InterruptedException e){}
}
elseif(Thread.currentThread()==blueBall)
{//以下代码为顺时针画圆
x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
bluePen.setColor(Color.gray);
bluePen.fillOval(150+x,100+y,10,10);
blueSeta-=3;
if(blueSeta<=-360)blueSeta=0;
x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
bluePen.setColor(Color.blue);
bluePen.fillOval(150+x,100+y,10;10);
try{blueBall.sleepp(40);}
catch(InterruptedException e){}
}
}
}
}
阅读程序,写出运行结果。
#include <iostream.h>
int a=5;
void fun(int b)
static int a=10;
a+=b++;
cout<< a;
void main()
{
int c=20:
fun(c);
a+Fc++
cout<<a<<endl
}
阅读下面程序,写出输出结果。
#include using namespace std ; class A { int a, b; public : A() { a = b = 0; }
A(int aa, int bb) { a = aa; b = bb; cout << a << ' ' << b << endl ; } }; int main() { A x, y(2,3);
return 0; }
第一题:写出下述程序结果:
int m[][3] = {1,4,7,2,5,8,3,6,9};
int i, j, k = 2;
for (i = 0; i < 3; i++) {
printf(“%d”, m[k]);