「字母金字塔java」字母金字塔c语言用for语句

博主:adminadmin 2023-01-10 23:27:07 950

今天给各位分享字母金字塔java的知识,其中也会对字母金字塔c语言用for语句进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java中金字塔 编程

import java.util.Scanner;

public class T {

  public static void main(String[] args) {

    System.out.println("请输入一个大写字母:");

    Scanner s = new Scanner(System.in);

    String input = s.next();

    if (input.length() != 1 || input.charAt(0)  65 || input.charAt(0)  90) {

      System.out.println("输入的不是一个大写字母。");

    }

    int c = input.charAt(0) - 65;

    for (int i = 0; i = c; i++) {

      for (int j = 25; j  i; j--) {

        System.out.print(" ");

      }

      for (int j = 0; j = i; j++) {

        System.out.print((char) (j + 65));

      }

      for (int j = i - 1; j= 0; j--) {

        System.out.print((char) (j + 65));

      }

      System.out.print("\n");

    }

  }

}

用JAVA编写金字塔

public class wode {

public static void main(String[] args) {

char[][] a = { { 'A' }, { 'B', 'B', }, { 'C', 'C', 'C', 'C' },

{ 'D', 'D', 'D', 'D', 'D', 'D' } };

for (int i = 0; i a.length; i++) {

for (int k = a.length - i; k 0; k--)

System.out.print(" ");

for (int j = 0; j a[i].length; j++) {

System.out.print(a[i][j]);

}

System.out.println();

}

}

}

基本上就这样,如果你要做得好看点,就自己改改空格的控制吧。

怎么用java编写金字塔?

public class King

{

public static void main(String argc[]) {

int t;

java.util.Scanner san = new java.util.Scanner(System.in);

System.out.print("请输入行数: ");

t = san.nextInt();

for (int i = 1; i = t; i++) {

for (int f = 1; f = (t - i); f++)

System.out.print(" ");

for (int ff = 1; ff = (2 * i - 1); ff++)

System.out.print("*");

System.out.println();

}

}

}

怎样用java写出字符金字塔的程序

public class Test{

public static void main(String[] args){

int i,j,k;

for(i=1;i=7;i++)

{

for(j=1;j=7-i;j++)

System.out.print(" ");

for(k=1;k=2*i-1;k++)

System.out.print("*");

System.out.print("\n");

}

}

}

JAVA以金字塔形式输出 1 2 3 4 5 6

int count = 1;

  int x = 3;

  for(int i=x;i0;i--){

   for (int j = 1; j  i; j++) {

    System.out.print(" ");

   }

   for (int K = 0; K = x-i; K++) {

    System.out.print(count);

    System.out.print(" ");

    count ++;

   }

   System.out.println("");

  }

关于字母金字塔java和字母金字塔c语言用for语句的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。