我的暱稱
2006-09-19 11:34:00 UTC
helloworld 後的第一篇就不行了, 請前輩們賜教, 先拜謝
-------------------------------------------------------------
public class NumberPersonalities {
public static void main(String[] args) {
int a = 1;
int b=2;
while ((a <= 101)&&(b<=100)) {
a=a+1;
b=b+1;
while (b <a) {
if (a % b == 0) {
System.out.println("is Composite");}
else {
System.out.println("is Prime");}
}
System.out.println(a+" ");
}
}
}
跑起來應該是
2 is Prime
3 is Prime
4 is Composite
.
.
.
100 is Composite
可是實際跑出來是
2
3
4
.
.
.
100
-----------------------------------------------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 165.123.137.149
-------------------------------------------------------------
public class NumberPersonalities {
public static void main(String[] args) {
int a = 1;
int b=2;
while ((a <= 101)&&(b<=100)) {
a=a+1;
b=b+1;
while (b <a) {
if (a % b == 0) {
System.out.println("is Composite");}
else {
System.out.println("is Prime");}
}
System.out.println(a+" ");
}
}
}
跑起來應該是
2 is Prime
3 is Prime
4 is Composite
.
.
.
100 is Composite
可是實際跑出來是
2
3
4
.
.
.
100
-----------------------------------------------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 165.123.137.149