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

熱點內容
香港伺服器如何做代理 瀏覽:199
pdf寫入 瀏覽:984
高爾夫電台怎麼添加到文件夾 瀏覽:237
四川麻將一般下哪個app 瀏覽:862
反編譯exe腳本 瀏覽:460
源碼文件夾怎麼編譯到固件中 瀏覽:912
ERp列印伺服器錯誤怎麼弄 瀏覽:113
蚌埠u盤加密軟體有哪些 瀏覽:178
前端如何認證伺服器 瀏覽:554
linux切換db2用戶命令 瀏覽:308
相片如何用電解壓 瀏覽:908
碩士程序員去學校當老師 瀏覽:120
pythonstr提取到字典 瀏覽:820
程序員那麼可愛有人看上陸漓了 瀏覽:878
php正則提取圖片 瀏覽:105
pythonlinuxdjango 瀏覽:564
php中文返回亂碼 瀏覽:91
宿舍裝的電信怎麼加密 瀏覽:747
為什麼壓縮文件解壓後變少了 瀏覽:428
現在安卓充電器普遍是什麼型號 瀏覽:717