Java输出正反金字塔循环 |
您所在的位置:网站首页 › JAVA输出星号 › Java输出正反金字塔循环 |
package com.javase.demo; import java.util.Scanner;
/** * 金字塔 * @author Mr.Zhang * */ public class Pyramid { static Scanner input = new Scanner(System.in); /** * *****打印金字塔***** * 1,确定金字塔行数 * 2,确认空格数 * 3,确认星星数 * @param args */ public static void main(String[] args) { entrance(); } /** * 入口项 */ public static void entrance() { System.out.println("请选择(0--正金字塔,1--倒金字塔,2--菱形金字塔)"); String select = input.nextLine(); if(isNumber(select)){ int selectInt = Integer.parseInt(select); switch(selectInt){ case 0: uprightPyramid(); break; case 1: fallPyramid(); break; case 2: System.out.println("该功能尚未完善!"); break; default: System.out.println("请输入正确的选项!"); entrance(); break; } }else if(!select.equals(0) || !select.equals(1) || !select.equals(2)){ nullSuccess(); } } /** * 打印正金字塔 * @param input */ public static void uprightPyramid() { System.out.println("请输入行数:"); String row = input.nextLine(); if(isNumber(row)){ int rows = Integer.parseInt(row); for(int i = 1;i |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |