import java.io.BufferedInputStream;
import java.util.Scanner;
public class T {
public static void main(String[] args) {
System.out.println("输入数字:");
Scanner in = new Scanner(new BufferedInputStream(System.in));
int n = in.nextInt();
int c = 'A';
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
System.out.print((char)c);
}
System.out.println();
c++;
}
}
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
int tmpCh = 'a';
for (int i = 0; i < count; i++)
{
int emptyCount = count - (i + 1);
int charCount = i + 1;
// 输出空格
for (int emptyIndex = 0; emptyIndex < emptyCount; emptyIndex++)
{
System.out.print(" ");
}
// 输出字符
for (int charIndex = 0; charIndex < charCount; charIndex++)
{
System.out.print((char)tmpCh);
}
System.out.println("");
tmpCh += 1;
}
}
10
a
bb
ccc
dddd
eeeee
ffffff
ggggggg
hhhhhhhh
iiiiiiiii
jjjjjjjjjj
public static void main(String[] args) {
System.out.println("打印几次");
Scanner scanner = new Scanner(System.in);
int num=0;
while (true) {
try {
String s = scanner.next();
num=Integer.parseInt(s);
System.out.println("打印什么");
Scanner scanner1 = new Scanner(System.in);
String content = scanner1.next();
for (int i = 0; i < num; i++) {
System.out.println("第"+(i+1)+"次:"+content);
}
} catch (NumberFormatException e) {
System.out.println("转换出错~");
}
}
}
//只要在 char字符范围之内,的都可以 ,您 输个 50 看看 ,再改改
更完美
package com.chinasoft;
import java.util.Scanner;
public class AtoZ {
public static void main(String[] args) {
System.out.print("\n请输入打印的行数:");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
//i 范围 char。min+64--char。max+64
for(int i=1;i<=n;i++) {
for(int j=1;j<=i;j++){
System.out.print((char)(64+i)+"\t");
}
System.out.println();
}
}
}
可否用正则表达式来实现!