一个数的循环输出

import java.util.*;
public class xunhuan {
public static void main(String[] args) {
int count =1;
Scanner m=new Scanner(System.in);
int n=m.nextInt();
while(count<=n)
{
if(count <n){
System.out.print(count+","); }
else
System.out.println(count);//最后一个数输出后换行
count++;//count增1,准备输出下一个数
}
}
}

运行结果:

posted on 2017-05-21 18:43  Iitb  阅读(135)  评论(0)    收藏  举报

导航