public?class?shu{
10多年的扎囊網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整扎囊建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“扎囊網(wǎng)站設(shè)計(jì)”,“扎囊網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
public?static?void?main(String[]?a){
for(int?i=0;i6;i++){
for(int?j=6-i;j0;j--){
System.out.print("?");
}
for(int?k=1;k=2*i+1;k++){
System.out.print("*");
}
System.out.println();
}?
/*以上是打印了一個(gè)上等腰三角形*/
for(int?i=6;i=0;i--){
for(int?j=6-i;j0;j--){
System.out.print("?");
}
for(int?k=1;k=2*i+1;k++){
System.out.print("*");
}
System.out.println();
}
}
}
只要把for的數(shù)據(jù)換下??下等腰三角形就出來(lái)了,所以原理其實(shí)就是打印2個(gè)等腰三角形
for(i=1;i=4;i++)
{
這個(gè)小的for是打印每一行前邊的空格
for(j=1;j=4-i;j++)
System.out.print(" ");
這個(gè)是打印星星的
for(j=1;j=2*i-1;j++)
System.out.print("*");
這個(gè)是打印完一行的換行
System.out.println("");
}
下邊的是一樣的 ?只不過(guò)每一行的空格和星星數(shù) ? 和上邊是翻過(guò)來(lái)的
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: 無(wú)效的列索引
無(wú)效的列索引
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ù)庫(kù)
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();
顯示效果是這樣的:
代碼如下:
int?hangshu?=?11;
int?yiban?=?hangshu?/?2?+?1;
int?yibanduo?=?hangshu?/?2;
System.out.println("空心菱形:");
for(int?k?=?1;k?=?yiban;k++){
for(int?i?=?1;i?=?(yiban?-?k);i++){
System.out.print("?");
}
System.out.print("*");
for(int?i?=?1;i?=?(?(k?-?2)?*?2?+?1);i++){
System.out.print("?");
}
if(k?!=?1){
System.out.print("*");????
}
System.out.println();
}
for(int?k?=?yibanduo;k?=1;k--){
for(int?i?=?1;i?=?(yiban?-?k);i++){
System.out.print("?");
}
System.out.print("*");
for(int?i?=?1;i?=?(?(k?-?2)?*?2?+?1);i++){
System.out.print("?");
}
if(k?!=?1){
System.out.print("*");????
}
System.out.println();
}
System.out.println("實(shí)心菱形:");
for(int?i?=?1;i?=?hangshu;i++){
if(i?=?hangshu/2?+?1){
for(int?k?=?1;k?=?hangshu/2?+?1-?i;k++){
System.out.print("?");
}
for(int?k?=?1;k?=?i;k++){
System.out.print("*?");
}
System.out.println();
}else{
for(int?k?=1;k?=?(i?-(hangshu/2?+?1));k++){
System.out.print("?");
}
for(int?k?=?1;k?=?(2?*(hangshu/2?+?1)?-?i);k++){
System.out.print("*?");
}
System.out.println();
}????
}
囧字再看看
已修改,復(fù)制粘貼即可
public?class?Diamond
{
public?static?void?main?(?String[]?args?)
{
printHollowRhombus?(10);
}
public?static?void?printHollowRhombus?(?int?size?)
{
if?(size?%?2?==?0)
{
size++;//?計(jì)算菱形大小
}
for?(?int?i?=?0;?i??size?/?2?+?1;?i++?)
{
for?(?int?j?=?size?/?2?+?1;?j??i?+?1;?j--?)
{
System.out.print?("?");//?輸出左上角位置的空白
}
for?(?int?j?=?0;?j??2?*?i?+?1;?j++?)
{
if?(j?==?0?||?j?==?2?*?i)
{
System.out.print?("*");//?輸出菱形上半部邊緣
}
else
{
System.out.print?("?");//?輸出菱形上半部空心
}
}
System.out.println?();
}
for?(?int?i?=?size?/?2?+?1;?i??size;?i++?)
{
for?(?int?j?=?0;?j??i?-?size?/?2;?j++?)
{
System.out.print?("?");//?輸出菱形左下角空白
}
for?(?int?j?=?0;?j??2?*?size?-?1?-?2?*?i;?j++?)
{
if?(j?==?0?||?j?==?2?*?(?size?-?i?-?1?))
{
System.out.print?("*");//?輸出菱形下半部邊緣
}
else
{
System.out.print?("?");
}
}
System.out.println?();
}
}
}
網(wǎng)站題目:java不空心菱形代碼 java實(shí)心菱形代碼
分享URL:http://m.newbst.com/article2/dosjgic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、關(guān)鍵詞優(yōu)化、建站公司、網(wǎng)站導(dǎo)航、商城網(wǎng)站、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)