真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼寫一個菱形 java代碼輸出菱形圖案

如何用java編寫用 "*"輸出菱形?

參考下面主要代碼:

10年積累的成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有留壩免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

public static void draw()

{

int n=10;

for(int i=1;i=n;i++)//控制行數(shù)

{

for(int k=n-1;k=i;k--)//打印空格

{

System.out.print(" ");

}

for(int j=1;j=2*i-1;j++)//打印*

{

System.out.print("*");

}

System.out.println();

}

for(int i=n-1;i=1;i--)

{

for(int k=i;k=n-1;k++)

{

System.out.print(" ");

}

for(int j=1;j=2*i-1;j++)

{

System.out.print("*");

}

System.out.println();

}

}

用java編寫菱形

for(i=1;i=4;i++)

{

這個小的for是打印每一行前邊的空格

for(j=1;j=4-i;j++)

System.out.print(" ");

這個是打印星星的

for(j=1;j=2*i-1;j++)

System.out.print("*");

這個是打印完一行的換行

System.out.println("");

}

下邊的是一樣的 ?只不過每一行的空格和星星數(shù) ? 和上邊是翻過來的

for(i=1;i=3;i++)

{

for(j=1;j=i;j++)

System.out.print(" ");

for(j=1;j=7-2*i;j++)

System.out.print("*");

System.out.println("");

}

java.sql.SQLException: 無效的列索引

無效的列索引

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:207)

atoracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:5328)

atoracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:5320)

at untitled5.addreader1.validID(addreader1.java:128)

at untitled5.addreader1.jButton1_actionPerformed(addreader1.java:97)

at untitled5.addreader1_jButton1_actionAdapter.actionPerformed(addreader1.java:175)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

代碼:String driverName = "oracle.jdbc.OracleDriver";

Driver driver = (Driver) Class.forName(driverName).newInstance();

//連接數(shù)據(jù)庫

Connection con = DriverManager.getConnection(

"jdbc:oracle:thin:@LONG:1521:orcl", "sysman", "tongfang");

PreparedStatement pstmt = con.prepareStatement(

" insert into reader values(?)");

pstmt.setString(1, str1);

pstmt.setString(2,str2);

pstmt.setString(3,str3);

pstmt.setString(4,str4);

ResultSet res = pstmt.executeQuery();

怎么用Java中的for循環(huán)寫出一個菱形 求講解

你好,提問者:

若解決了你的問題請采納,若有疑問請追問,謝謝!

這個菱形應(yīng)該是由四個三角形組成,上面兩個三角下面兩個三角,拼接而成的。下面給你寫了個例子:

public?class?LingXing2?{

public?static?void?main(String[]?args)?{

//菱形

CeSanJiao(6);

}

public?static?void?CeSanJiao(int?number){

//上半截

?for(int?i=1;i=number;i++){

?if(i==1){

?for(int?lage=1;lagenumber;lage++){

?System.out.print("-");

?}

?for?(int?j?=?i;?j0?;?j--)?{//列數(shù)

System.out.print("*");

}

?System.out.println();

?}else{

?//反正三角

? for(int?j=i;j1;j--){

? if(j==i){

? for(int?lage=1;lage=number-i;lage++){

?System.out.print("-");

?}

? }

? System.out.print("*");

? }

? //正三角

? for?(int?j?=?i;?j0?;?j--)?{//列數(shù)

System.out.print("*");

}

? System.out.println();

?}

}

?//下半截

?for(int?i=1;i=number;i++?){

?if(i==(number-1)){

?for(int?lage=i;lage(number-i-1);lage--){

?System.out.print("-");

?}

?System.out.println("*");

?}else{

?//反倒三角

?for(int?j=number-i;j=1;j--){

?if(j==(number-i)){

? for(int?lage=number;lage(number-i);lage--){

?System.out.print("-");

?}

? }

? System.out.print("*");

? }

?//倒三角

?for(int?j?=?1;?j??number?-i;?j++){//列數(shù)

System.out.print("*");

}

?}

System.out.println();

?}

}

}

結(jié)果:

-----*

----***

---*****

--*******

-*********

***********

-*********

--*******

---*****

----***

-----*


當(dāng)前標(biāo)題:java代碼寫一個菱形 java代碼輸出菱形圖案
標(biāo)題網(wǎng)址:http://weahome.cn/article/dddpsph.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部