扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
我给你写了一个,参考一下吧。。import java.util.*;
铁力网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联建站从2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站。
public class H
{
public static void main(String args[])
{
int a,b,c,N;
System.out.println("请输入菱形的边长N");
N=new Scanner(System.in).nextInt();
for(a=0;aN;a++)
{
for(b=0;b=N-a;b++)
System.out.print(" ");
for(c=1;c=2*a-1;c++)
{
if(c==1||c==2*a-1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.print("\n");
}
for(a=0;a=N;a++)
{
for(b=0;b=a;b++)
System.out.print(" ");
for(c=1;c=2*(N-a)-1;c++)
if(c==1||c==2*(N-a)-1)
System.out.print("*");
else
System.out.print(" ");
System.out.print("\n");
}
}
}
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("");
}
下边的是一样的 只不过每一行的空格和星星数 和上边是翻过来的
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();
//连接数据库
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();
import java.util.Scanner;
public class Diamond {
public static void main(String[] args) {
int length=1;//存储菱形的边长的变量
Scanner sc =new Scanner(System.in);//输入数据的扫描对象
System.out.println("请输入菱形的边长:");
length = sc.nextInt();//获取输入的边长数值
/*打印菱形的上半部分三角形 行数为length行*/
for (int i=1; i=length;i++) {//需要打印的行数
for(int j=1;j=length-i;j++){//打印左边空白的区域,随行递减1
System.out.print(" ");
}
for(int k=1;k=2*i-1;k++){//打三角形的区域
if(k==1||k==2*i-1){//空心的获取 除每行第一个以及最后一个 外其余为空白
System.out.print("*");
}else{
System.out.print(" ");
}
}
System.out.println();
}
/*打印菱形的下半部分三角形 中间行公用 故行数为length-1*/
for (int i = length-1;i0;i--){
for(int j=1;j=length-i;j++){
System.out.print(" ");
}
for(int k=1;k=2*i-1;k++){
if(k==1||k==2*i-1){
System.out.print("*");
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}
Console.Write("请输入要打印的行数(奇数):");
int n = int.Parse(Console.ReadLine()) / 2 + 1; //这样就算出上部分的总行数了
for (int i = 1; i = n; i++)
{
for (int j = 1; j = n - i; j++)
{
Console.Write(" ");
}
for (int k = 1; k = 2 * i - 1; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
for (int i = 1; i n; i++)
{
for (int j = 1; j = i; j++)
{
Console.Write(" ");
}
for (int k = 1; k = (2 * n - 1) - 2 * i; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流