标题:多个数的平方与立方
只看楼主
lico709394
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-4-22
 问题点数:0 回复次数:1 
多个数的平方与立方

import java.io.*;

class InputData {
static private String s = "";
static public void input() {
BufferedReader bu = new BufferedReader(
new InputStreamReader(System.in)
);
try {
s = bu.readLine();
}
catch (IOException e) {}
}

static public int getInt() {
input();
return Integer.parseInt(s);
}
}

class Result {
void print(int d) {
System.out.println(d + "的平方:" + d * d);
System.out.println(d + "的立方:" + d * d * d);
}
}

public class PrintResult {
public static void main(String[] args) {
Result result = new Result();
System.out.println("请输入一个整数:");
int a = InputData.getInt();
result.print(a);
}
}
我只懂得逐个逐个熟输出...请问那位高手可以告诉我怎么多个数输出?

搜索更多相关主题的帖子: 立方 平方 
2007-04-26 22:23
liucheng
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-4-26
得分:0 
可以把所要计算的多个数保存在数组里
然后把数组做为参数传多方法里面 在方法里用循环对数组里的每个值求平方和立方
2007-04-27 18:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-135263-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.645866 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved