首页 > 考试题库
题目内容 (请给出正确答案)
[主观题]

写出程序运行结果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));

}

}

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“写出程序运行结果int sum(int a){auto in…”相关的问题
第1题
写出以下程序的运行结果。#include int fun(int a){int b=0;static int c=3;b ; c ;return(a
写出以下程序的运行结果。#include int fun(int a){int b=0;static int c=3;b ; c ;return(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)<< " ";}

点击查看答案
第2题
写出以下程序的运行结果。public class Test2 {public static void main(String args[ ]){int i,j

写出以下程序的运行结果。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();} }

点击查看答案
第3题
写出以下程序的运行结果

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);

}

}

点击查看答案
第4题
下面的Java程序运行结束后,sum的值是()。int sum = 0;for(int i=1; i<=3; i++){for(int j=1; j<=i; j++){sum++;}}

A.9

B. 6

C. 3

D. 0

点击查看答案
第5题
已知某程序的界面包含一个文本区text1、一个文本框text2和一个按钮button。下面是该程序的相关
方法。阅读下面方法,写出该方法功能。

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);

}

}

点击查看答案
第6题
阅读下列程序,请写出程序的运行结果。import java.applet.*;import java.awt.*;public class C

阅读下列程序,请写出程序的运行结果。

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){}

}

}

}

}

点击查看答案
第7题
阅读程序,写出运行结果。#include <iostream.h>int a=5;void fun(int b)static int a=10;a+=b++
阅读程序,写出运行结果。#include <iostream.h>int a=5;void fun(int b)static int a=10;a+=b++

阅读程序,写出运行结果。

#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

}

点击查看答案
第8题
阅读下面程序,写出输出结果。#include using namespace std ; class A { int a, b; public :
阅读下面程序,写出输出结果。#include using namespace std ; class A { int a, b; public :

阅读下面程序,写出输出结果。

#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; }

点击查看答案
第9题
第一题:写出下述程序结果:int m[][3] = {1,4,7,2,5,8,3,6,9};int i, j, k = 2;for (i = 0; i <

第一题:写出下述程序结果:

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]);

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改