package com.wh.lingxing; import java.util.Scanner; public class LingXing { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (;;) { System.out.println("请输入个数:"); int num = sc.nextInt(); int num2 = 0; if (num % 2 =
19 [程序 19 打印菱形图案] 题目:打印出如下图案(菱形) * *** ************ ***** *** * 程序分析:先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重 for 循环,第一层 控制行,第二层控制列. package cskaoyan; public class cskaoyan19 { @org.junit.Test public void rhombus() { for (int i = 0; i < 4; i++)
/** * 使用for循环输出空心菱形 * */ public class Test7 { public static void main(String[] args) { for (int i = 1; i <= 5; i++) { for (int j = 1; j < 11 - 2 * i; j++) { System.out.print(" "); } for (int k = 1; k <= 2 * i - 1; k++) { if (k == 1 || k
打印菱形图案: 代码实现: public class Hello { public static void main(String args[]) { LingXingPrint("#", 7); } public static void LingXingPrint(String i, int num) { /** * 打印菱形,传参:i 为打印的字符,num为行数 . * 思路:将菱形分为上三角和下三角,上三角:每一行空格打印数为总行数-行号:每一行字符打印个数为2*行号-1;下三角
for(int a = 5; a > 0 ; a--){ for(int b = 1; b <= a; b++){ System.out.print(" "); } for(int c = 5; c >= a; c--){ System.out.print("* "); } System.out.println(" "); } for(int a = 4; a > 0 ; a--){ for(int d = 1; d &g
package javafirst; public class HomeWork { public static void main(String[] args){ System.out.println("输出一个菱形!"); for(int i = 0; i < 5; i ++){ for(int j = 5; j > i + 1; j--){ System.out.print(" "); } for(int k = 0; k < 2*i + 1
for (int i = 1; i <= 11; i++) // i 的起始值是一 在<=11; 逐个递增 { int a, b, c;// 定义abc三数 for (a = 11; a > i; a--) // a这是个递减的 起始值是11 当i=1时 // a的值是11 输出11个空白 Console.Write(" "); for (b = 1; b <= i; b++)// 当以上输出11个空白时 b输出一个“*”以此类推 Console.Write(&