Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
12
返回列表 发新帖
楼主: jayte2168
打印 上一主题 下一主题

JAVA问题 请各位高手来看看并给与帮助

[复制链接]

9

主题

11

好友

303

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

11#
发表于 2014-10-9 01:36 PM |只看该作者
本帖最后由 jayte2168 于 2014-10-9 02:32 PM 编辑
htuomrev 发表于 2014-10-8 11:09 AM
为了方便和意义完整,factor我是包括input本身,如果sum of factor 不需要 input 本身,那:再减掉 input 的 ...


Now teacher adding some trouble to me zzzzz

She want me to prompt number of values to test which means i hv to add loop.

For examples,
Please write the numbers of value to test.
4
Please write the 1st number to test.
60
Please write the 2nd number to test.
80
Please write the 3rd number to test.
100
Please write the 4st number to test.
500


回复

使用道具 举报

6

主题

1

好友

1943

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

12#
发表于 2014-10-9 10:13 PM |只看该作者
jayte2168 发表于 2014-10-9 01:36 PM
Now teacher adding some trouble to me zzzzz

She want me to prompt number of values to test wh ...


只要增加几个 looping 就可以了,然后用一个list来记录input的number,我举个例子:
  1. Scanner sc = new Scanner(System.in);
  2. S.O.P("How many number want to test? ");
  3. int size = sc.nextInt();

  4. List<Integer> numbers = new ArrayList(0);
  5. for (int i=0;i<size;i++) {
  6.   S.O.P("Number " + (i+1) + "?");
  7.   int input = sc.nextInt();
  8.   numbers.add(input);
  9. }

  10. for (Integer num : numbers) {
  11.   printResult(sumOfFactors(getFactors(num)), num);
  12. }
复制代码
这个是直接打的,没测试,逻辑大概就是这样而已。
PS: S.O.P = System.out.println


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-12-26 02:33 PM , Processed in 0.087752 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部