導航:首頁 > 源碼編譯 > 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簡單愛心圖案源碼相關的資料

熱點內容
為什麼說伺服器沒有響應 瀏覽:971
linux怎麼搭web伺服器 瀏覽:253
房產證加密收費嗎 瀏覽:153
slam演算法處理數據 瀏覽:267
如何判斷伺服器ip地址和版本號 瀏覽:965
python獲取html內容 瀏覽:770
北歐大神程序員 瀏覽:205
安卓手機怎麼拍出照片的質感 瀏覽:835
編譯後的病毒長什麼樣子 瀏覽:23
圍棋與程序員 瀏覽:260
加密和解密的單詞 瀏覽:983
我的世界td伺服器怎麼注冊 瀏覽:415
編譯器的堆空間 瀏覽:601
雲引擎雲伺服器 瀏覽:911
解壓視頻聲控吃冰義大利 瀏覽:408
渦旋壓縮機動渦盤 瀏覽:881
手機郵件發文件夾 瀏覽:451
魔獸世界懷舊服tbc薩滿宏命令 瀏覽:549
linuxsvn手冊 瀏覽:271
程序員圖鑒 瀏覽:539