键盘输入
最多36行
前26行为ABC26个字母 后10行为0-9
△ 请用简单的代码写出来

解决方案 »

  1.   

    int a[36][36]={0,0};
    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");
    }
      

  2.   

    答:明白了.代码:public class Tri {
    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("");
          
         }
         
    }}
      

  3.   

    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("");
    }
    }
    }
      

  4.   

    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(""); 


    }
      

  5.   

    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(""); 


    }