循环输出26个字母

循环输出26个字母

package com.jinglan.loop;

public class WhileCirculation {
    
    
	public static void main(String[] args) {
    
    
		// 循环输出26个英文字母
		char ch = 'a';
		while (ch <= 'z') {
    
    
			System.out.print(ch + " ");
			ch++;
		}
	}
}

运行结果
在这里插入图片描述

循环输出26个字母并且分两行输出

package com.jinglan.loop;

public class WhileCirculation {
    
    
	public static void main(String[] args) {
    
    
		//循环输出26个英文字母,分两行输出
		char ch = 'a';
		int count=1;//记录
		while(ch<='z') {
    
    
			System.out.print(ch+" ");
			ch++;
			if(count==13) {
    
    
				System.out.println();
			}
			count++;
			
		}
	}
}

运行结果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/muyuxifeng/article/details/112757516