import javax.swing.JOptionPane;public class Test { public static void main(String[] args) { String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!"); try{ int line = Integer.parseInt(str); if(line>36||line<0){ JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!"); }else{ new Test().triPrint(line); } }catch(Exception e){ JOptionPane.showMessageDialog(null, "行数必须是整数!"); } }
private void triPrint(int line){ int d = 35; char ch = 'a'; for (int i = 1; i <= line; i++, d--, ch++) { if (i == 27) ch = '0'; for (int j = 1; j <= d; j++) System.out.print(" "); for (int j = 1; j <= 2 * i - 1; j++) System.out.print(ch); System.out.println(""); } } }
import javax.swing.JOptionPane;public class tri { public static void main(String[] args) { int line; try{ do{ String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!"); line = Integer.parseInt(str); JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!"); }while(line>36||line <0); new tri().triPrint(line);
}catch(Exception e){ JOptionPane.showMessageDialog(null, "行数必须是整数!"); } } private void triPrint(int line) { int d = 35; char ch = 'a'; for (int i = 1; i <= line; i++, d--, ch++) { if (i == 27) ch = '0'; for (int j = 1; j <= d; j++) System.out.print(" "); for (int j = 1; j <= 2 * i - 1; j++) System.out.print(ch); System.out.println(""); } } }
import javax.swing.JOptionPane;public class tri { public static void main(String[] args) { new tri().tripro(); } public void tripro() { int line; try{ do{ String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!"); line = Integer.parseInt(str); if(line>36||line <0) JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!"); else JOptionPane.showMessageDialog(null, "输入成功!"); }while(line>36||line <0); new tri().triPrint(line);
}catch(Exception e){ JOptionPane.showMessageDialog(null, "行数必须是整数!"); new tri().tripro(); } }private void triPrint(int line) { int d = 35; char ch = 'a'; for (int i = 1; i <= line; i++, d--, ch++) { if (i == 27) ch = '0'; for (int j = 1; j <= d; j++) System.out.print(" "); for (int j = 1; j <= 2 * i - 1; j++) System.out.print(ch); System.out.println(""); } } }
int i,j;
char b='A';
for(i=0;i<=10;i++)
{
if(i<10)
{
for(j=0;j<i;j++)
printf("%d",a[i][j]+i);
}
else
for(j=0;j<=i+25;j++)
printf("%c",a[i][j]+b);
printf("\n");
}
public static void main(String[] args) {
int d=35;
char ch='a';
for(int i=1;i<=36;i++,d--,ch++)
{
if(i==27) ch='0';
for(int j=1;j<=d;j++) System.out.print(" ");
for(int j=1;j<=2*i-1;j++) System.out.print(ch);
System.out.println("");
}
}}
public static void main(String[] args) {
String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!");
try{
int line = Integer.parseInt(str);
if(line>36||line<0){
JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!");
}else{
new Test().triPrint(line);
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, "行数必须是整数!");
}
}
private void triPrint(int line){
int d = 35;
char ch = 'a';
for (int i = 1; i <= line; i++, d--, ch++) {
if (i == 27)
ch = '0';
for (int j = 1; j <= d; j++)
System.out.print(" ");
for (int j = 1; j <= 2 * i - 1; j++)
System.out.print(ch);
System.out.println("");
}
}
}
public static void main(String[] args)
{
int line;
try{
do{
String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!");
line = Integer.parseInt(str);
JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!"); }while(line>36||line <0); new tri().triPrint(line);
}catch(Exception e){
JOptionPane.showMessageDialog(null, "行数必须是整数!");
}
} private void triPrint(int line)
{
int d = 35;
char ch = 'a';
for (int i = 1; i <= line; i++, d--, ch++)
{
if (i == 27)
ch = '0';
for (int j = 1; j <= d; j++)
System.out.print(" ");
for (int j = 1; j <= 2 * i - 1; j++)
System.out.print(ch);
System.out.println("");
}
}
}
public static void main(String[] args)
{
new tri().tripro();
}
public void tripro()
{
int line;
try{
do{
String str = JOptionPane.showInputDialog(null,"请输入三角形的行数!");
line = Integer.parseInt(str);
if(line>36||line <0)
JOptionPane.showMessageDialog(null, "三角形的行数必须在0到36之间!");
else
JOptionPane.showMessageDialog(null, "输入成功!");
}while(line>36||line <0); new tri().triPrint(line);
}catch(Exception e){
JOptionPane.showMessageDialog(null, "行数必须是整数!");
new tri().tripro();
}
}private void triPrint(int line)
{
int d = 35;
char ch = 'a';
for (int i = 1; i <= line; i++, d--, ch++)
{
if (i == 27)
ch = '0';
for (int j = 1; j <= d; j++)
System.out.print(" ");
for (int j = 1; j <= 2 * i - 1; j++)
System.out.print(ch);
System.out.println("");
}
}
}