導航:首頁 > 源碼編譯 > java簡單愛心圖案源碼

java簡單愛心圖案源碼

發布時間:2024-03-23 13:23:09

A. 如何用java在頁面上用循環列印一個愛心形狀

import java.util.Scanner;

public class test{

static void draw(int n)
{
int i,j;
for (i=1-(n>>1);i<=n;i++)
if (i>知仿拿0)
{
for (j=0;j<i;j++) System.out.print("大瞎 ");
for (j=1;j<=2*(n-i)+1;j++)
if (j==1||j==2*(n-i)+1) System.out.print(" *");
else System.out.print(" ");
System.out.println("\n");
}
else
if (i==0)
{
System.out.print(" *");
for (j=1;j<n;j++) System.out.print(" ");
System.out.print(" *");
for (j=1;j<n;j++) System.out.print(" ");
System.out.print(" *\n");
}
else
{
for (j=i;j<0;j++) System.out.print(" ");
for (j=1;j<=n+2*i+1;j++)
if (i==1-(n>>1)) System.out.print(" *"搭搭);
else if (j==1||j==n+2*i+1) System.out.print(" *");
else System.out.print(" ");
for (j=1;j<=-1-2*i;j++) System.out.print(" ");
for (j=1;j<=n+2*i+1;j++)
if (i==1-(n>>1)) System.out.print(" *");
else if (j==1||j==n+2*i+1) System.out.print(" *");
else System.out.print(" ");
System.out.print("\n");
}
}
public static void main(String[] args) {

System.out.println("Please input the size (n>=4):");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
draw(n);

}

}先說明這個不是我寫的 是看了有人用C語言寫的 就順便改成了java 結果有點像愛心 還湊合著 你看看怎麼樣吧 哈

閱讀全文

與java簡單愛心圖案源碼相關的資料

熱點內容
編譯原理定義表格和編寫查找函數 瀏覽:346
指數函數和對數函數的高精度快速演算法 瀏覽:207
c預編譯干什麼 瀏覽:24
hp網路共享文件夾 瀏覽:365
程序員如何不被廢 瀏覽:806
二進制流轉pdf 瀏覽:916
php判斷爬蟲 瀏覽:571
960除24除4簡便演算法 瀏覽:786
關於解壓英語翻譯 瀏覽:565
python控制鍵盤右鍵 瀏覽:921
php沒有libmysqldll 瀏覽:828
時政新聞app哪個好 瀏覽:906
手機已加密怎麼辦 瀏覽:201
安卓手機截屏怎麼傳到蘋果 瀏覽:529
京管家app哪裡下載 瀏覽:33
文件夾橫向排列的豎向排列 瀏覽:453
51單片機驅動攝像頭模塊 瀏覽:689
政府文件加密沒法轉換 瀏覽:373
android判斷棧頂 瀏覽:331
憑證軟體源碼 瀏覽:860