一个数的循环输出
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,准备输出下一个数
}
}
}
运行结果:

浙公网安备 33010602011771号