JAVA如何确定输出(循环)次数?
答案:2 悬赏:70
解决时间 2021-01-17 14:10
- 提问者网友:心如荒岛囚我终老
- 2021-01-17 08:39
JAVA如何确定输出(循环)次数?
最佳答案
- 二级知识专家网友:雪起风沙痕
- 2021-01-17 08:52
搞个变量记录
class A{
static int count;
public static void main(String[] args) {
for(int i = 0; i < Integer.parseInt(args[0]); i++) {
count++;
}
System.out.print("循环了:"+count+"次");
}
}
class A{
static int count;
public static void main(String[] args) {
for(int i = 0; i < Integer.parseInt(args[0]); i++) {
count++;
}
System.out.print("循环了:"+count+"次");
}
}
全部回答
- 1楼网友:第幾種人
- 2021-01-17 09:01
满足了条件呀。比如
int a=0;
while(a<2){
system.out.println("abc")
a=a+1;
}
比如这个循环吧,就一共输出了2次。
int a=0;
while(a<2){
system.out.println("abc")
a=a+1;
}
比如这个循环吧,就一共输出了2次。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息