码迷,mamicode.com
首页 > 其他好文 > 详细

自己原创线路 有缺陷代码

时间:2019-04-03 22:25:58      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:石家庄   cti   ansi   input   pos   orm   style   width   warnings   

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<style type="text/css">
        *  {margin:0;padding:0;}/*去掉页面样式*/
           body{color:white;}
          .content{
              background-color:black;
            left:0;
            max-width: 100%;
             height:120px;
             /*margin-top:00px;
              margin-left:00px;
              margin-right:600px;
            overflow:hidden;/*隐藏滚动条*/
        margin:50 auto;/*设置上右下左,居中显示*/
          
         }
           .content1{
              background-color:white;
            left:0;
            max-width: 100%;
             height:60px;
             /*margin-top:00px;
              margin-left:00px;
              margin-right:600px;
            overflow:hidden;/*隐藏滚动条*/
        margin:50 auto;/*设置上右下左,居中显示*/
          
         }
         .content2{
              background-color:green;
            left:0;
            max-width: 100%;
             height:60px;
             /*margin-top:00px;
              margin-left:00px;
              margin-right:600px;
            overflow:hidden;/*隐藏滚动条*/
        margin:50 auto;/*设置上右下左,居中显示*/
         background:blue;
          
         }
         .main{
            text-align:center;/*文本居中*/
             width:100%;
             height:400px;
             padding:100px 0px;/*上下80px,左右为0*/
             background:gray;/*验证div的位置*/
            margin:0 auto;/*设置上右下左,居中显示*/
           
         }
         .content h1{
             font-family:"LiSu";/*设置字体*/
             font-size:30px;/*设置字体大小*/
             font-weight:2px;/*调整字体粗细*/
             color: white;/*设置字的颜色*/
        }
         .content h2{
             font-family:"YOUYUAN";/*设置字体*/
             font-size:25px;/*设置字体大小*/
             font-weight:1px;/*调整字体粗细*/
             color: green;/*设置字的颜色*/
        }
        .content h3{
             font-family:"SONGTI";/*设置字体*/
             font-size:20px;/*设置字体大小*/
             font-weight:0.5px;/*调整字体粗细*/
             color: purple;/*设置字的颜色*/
        }
        .content2 h5{
               font-family:"宋体";/*设置字体*/
             font-size:25px;/*设置字体大小*/
             font-weight:2px;/*调整字体粗细*/
             color: white;/*设置字的颜色*/
        }   
        #slideShowContainer{
    width: 425px;
    height: 325px;
    margin-top: 10px;
    margin-left: 10px;
    overflow: hidden;
    position: relative;
}
#slideShowContainer img{
    width: 425px;
    height: 325px;
    transition: all 0.6s;
}
#slideShowContainer img:hover{
    transform: scale(1.07);
}
#picUl{
    list-style: none;
}
#dotUl{    
    list-style: none;
    display: flex;
    flex-direction: row;
    position: absolute;  //使用绝对布局,固定于左下角
    right: 21px;
    bottom: 15px;
    z-index: 2;  //通过设置z-index的值大于#titleDiv中z-index的值,使其浮在标题栏的上方
    }
#titleDiv{
    position: absolute;
    width: 100%;
    height: 42px;
    bottom: 0px;
    left: 0px;
    background-color: #000000;
    opacity:0.6;  //设置透明度,实现标题栏半透明效果
    z-index: 1;
}
#titleDiv>span{
    line-height: 42px;
    color: #FFFFFF;
    margin-left: 20px;
    width: 270px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#titleDiv>span>a{
    color: #FFFFFF;
}
.selected{
    width: 12px;
    height: 12px;
    background-color: #FFFFFF;
    color: transparent;
     margin-left: 9px;
}
.unselected{
    width: 12px;
    height: 12px;
    background-color: #0069AD;
    color: transparent;
    margin-left: 9px;
}
.hide{
    display: none;
}
.show{
    display: block;
}
     </style>
</head>
<body>
<div class="content">
  <table>
   <tr>
    <td width="100px"><h1>石家庄</h1></td>
                    <td width="200"><h2>地铁服务系统</h2></td>
    <td width="60px"><a href="1.html"><h3>首页</h3></a></td>
                    <td width="80px"><a href="C:\Users\97890\Desktop\8.html"><h3>关于地铁乘车信息</h3></a></td>
                    <td width="60px"><a href="https://www.cnblogs.com/"><h3>确认提交您的选择路线</h3></a></td>
                    <td width="60px"><a href="https://www.cnblogs.com/"><h3>留言</h3></a></td>
                    <td width="60px"><a href="https://www.cnblogs.com/"><select name="select" id="" display:none><option value="" display:none><h3>娱乐</h3></option><option value=""><h3>音乐鉴赏</h3></option><option value=""><h3>游戏</h3></option></select></a></td>
                   
   </tr>
  </table>
 </div>
 <hr>
          <div class="content1">
           <table>
            <tr>
             <td width="1500px"><img src="C:\Users\97890\Desktop\JAVA地铁工程图片/1.jpg" width="600" height="60px" ></td>
             <td><a href="C:\Users\97890\Desktop\JAVA地铁工程图片/1.jpg"><img src="C:\Users\97890\Desktop\JAVA地铁工程图片/1.jpg" width="600px" height="60px" ></a></td>
            </tr>
           </table>
          </div>
          <hr>
 <div class="main">
 <table>
  <tr>
   <td width="1000px"><img src="C:\Users\97890\Desktop\JAVA地铁工程图片/3.jpg" width="1000px" height="500px" /></td>
 
   <td width="200px">
   <form action="ceshi.jsp" method="post">
    请输入起始站线路:<input type="text" name="number1"/><br>
    请输入起始站:<input type="text" name="name1"/><br>
    请输入终点站线路:<input type="text" name="number2"/><br>
    请输入终点站:<input type="text" name="name2"/><br>
    <input type="submit" value="查询自己的路线">
   </form></td>
  </tr>
 </table>
 
 </div>
 
 
</body>
</html>
show。jsp
<%@ page language="java" contentType="text/html; charset=utf-8"%>
 <%@ page import="java.sql.*" %>
  <%@ page import="地铁.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>获得站名</title>
</head>
<body>
<%
 String url="jdbc:mysql://localhost:3306/road";
 String user="root";
 String password="root";
 String[] aaa=new String[158];
 Connection conn=null;
  try{Class.forName("com.mysql.jdbc.Driver");//加载JDBC程序驱动
  conn =DriverManager.getConnection(url,user,password);
  
  }catch (ClassNotFoundException e){
   out.println("加载驱动失败");          //处理ClassNotFoundException的异常
  }catch(SQLException e){
   out.println("连接MYSQL数据库失败");
  }
  try{
   //创建语句对象Statement
   Statement stmt=conn.createStatement();
   //站名
   String queryAll="SELECT name FROM lineone;";
   //执行查询
   ResultSet rs=stmt.executeQuery(queryAll);
   int i=0;
   while(rs.next()){
    //获得站名
    aaa[i]=rs.getString(1);
    i++;
   }
  }catch(SQLException e){
   out.println("查询所有站点失败");
  }
  for(int i=0;i<158;i++){
   out.println("\""+aaa[i]+"\""+",");
   
  }
  line c=new line();
  response.setContentType("text/html;charset=utf-8");
 request.setCharacterEncoding("utf-8");
    String name1=request.getParameter("name1");
    String name2=request.getParameter("name2");
    int a = Integer.parseInt(request.getParameter("number1"));
   int b = Integer.parseInt(request.getParameter("number2"));
   //if(a==5){
  //  out.println("大声告诉我");
   //}
   //if(b==1){
 //   out.println("b==1"+name1+name2);
   //}
  // out.println(name1);
    c.nu(name1,name2,a,b,aaa);
%>
</body>
</html>
cishi.java
package 地铁;
import 地铁.line;
public class line {
 @SuppressWarnings("null")
 public void nu(String a,String b,int line1,int line2,String[] aaa) {
  String aa[]=new String[158];
  for(int i=0;i<158;i++) {
   aa[i]=aaa[i]; 
  }
  int qizhanid=0;  //起点站和终点站记录
  int zhongzhanid=0;
  int change1=0;//换成站id记录
  int change2=0;
  int number1=0;
  int number2=0;
  int n1=0;
  int n2=0;
  if(line1!=line2) {
  switch(line1) {
  case 1:
   n1=29;
  break;
  case 2:
   n1=37;
  break;
  case 3:
   n1=34;
  break;
  case 4:
   n1=18;
  break;
  case 5:
   n1=21;
  break;
  case 6:
   n1=19;
  break;
  }
  switch(line2) {
  case 1:
   n2=29;
  break;
  case 2:
   n2=37;
  break;
  case 3:
   n2=34;
  break;
  case 4:
   n2=18;
  break;
  case 5:
   n2=21;
  break;
  case 6:
   n2=19;
  break;
  }
  
  String zancun1[]=new String[n1] ;
  String zancun2[]=new String[n2] ;
  
  //将两个起始站和终点站路线分别存在不同的数组zancun1和zancun2中
  switch (line1) {
  case 1:
  for(int i=0;i<29;i++)
  {
            zancun1[i]=aa[i];
   
  }
  break;
  case 2:
   for(int i=0;i<37;i++)
   {
    zancun1[i]=aa[i+29];
    
   }
   break;
  case 3:
   for(int i=0;i<34;i++)
   {
             zancun1[i]=aa[i+66];
    
   }
   break;
     case 4:
    for(int i=0;i<18;i++)
    {
     zancun1[i]=aa[i+100];
     
    }
    break;
     case 5:
    for(int i=0;i<21;i++)
    {
              zancun1[i]=aa[i+118];
     
    }
    break;
  case 6:
    for(int i=0;i<19;i++)
    {
      zancun1[i]=aa[i+139];
      
    }
     break;
  }
  switch (line2) {
  case 1:
   for(int i=0;i<29;i++)
   {
             zancun2[i]=aa[i];
    
   }
   break;
   case 2:
    for(int i=0;i<37;i++)
    {
     zancun2[i]=aa[i+29];
     
    }
    break;
   case 3:
    for(int i=0;i<34;i++)
    {
              zancun2[i]=aa[i+66];
     
    }
    break;
      case 4:
     for(int i=0;i<18;i++)
     {
      zancun2[i]=aa[i+100];
      
     }
     break;
      case 5:
     for(int i=0;i<21;i++)
     {
               zancun2[i]=aa[i+118];
      
     }
     break;
   case 6:
     for(int i=0;i<19;i++)
     {
       zancun2[i]=aa[i+139];
       
     }
      break;
  }
  //获得地铁路线的换乘车站change1和change2
  outer:for(int i=0;i<zancun1.length;i++) {
   for(int j1=0;j1<zancun2.length;j1++) {
    if(zancun1[i].equals(zancun2[j1])){
     change1=i;
     change2=j1;
     break outer;
    }
   }
    
  }
 //for循环实现对起始站换乘站及以前站的输出 
   //获得起始站id
   for(int i=0;i<zancun1.length;i++) {
    if(zancun1[i].equals(a)) {
     qizhanid=i;
     break;
    }
           }
   //两中情况判断起始站到中转站路径
  if(qizhanid<=change1) {
   for(int i=qizhanid;i<=change1;i++) {
   System.out.println(zancun1[i]+"   ");
   if(i==change1) {
    System.out.println("***次站为换乘车站");
   }
   } 
        }else {
   for(int i=qizhanid;i>=change1;i--) {
   System.out.println(zancun1[i]+"   ");
   if(i==change1) {
    System.out.println("***次站为换乘车站");
   }
          }       
              }
  
           
  
  //for循环实现换乘车站从中转路径到终点站的输出
   //获得终点站zhongzhanid
   for(int i=0;i<zancun2.length;i++) {
    if(zancun2[i].equals(b)) {
     zhongzhanid=i;
     break;
    }
           }
   //两中情况判断起始站到中转站路径
  if(zhongzhanid<=change2) {
   for(int i=change2-1;i>=zhongzhanid;i--) {
   System.out.println(zancun2[i]+"   ");
   } 
        }else {
   for(int i=change2+1;i<=zhongzhanid;i++) {
   System.out.println(zancun2[i]+"  ");
          }       
              }
            } 
  else if(line1==line2)
     //在同一条线上的直线输出       
            {
   switch(line1) {
   case 1:
    n1=29;
   break;
   case 2:
    n1=37;
   break;
   case 3:
    n1=34;
   break;
   case 4:
    n1=18;
   break;
   case 5:
    n1=21;
   break;
   case 6:
    n1=19;
   break;
   }
   String zancun1[]=new String[n1] ;
      switch (line1) {
      case 1:
      for(int i=0;i<29;i++)
      {
                zancun1[i]=aa[i];
       
      }
      break;
      case 2:
       for(int i=0;i<37;i++)
       {
        zancun1[i]=aa[i+29];
        
       }
       break;
      case 3:
       for(int i=0;i<34;i++)
       {
                 zancun1[i]=aa[i+66];
        
       }
       break;
         case 4:
        for(int i=0;i<18;i++)
        {
         zancun1[i]=aa[i+100];
         
        }
        break;
         case 5:
        for(int i=0;i<21;i++)
        {
                  zancun1[i]=aa[i+118];
         
        }
        break;
      case 6:
        for(int i=0;i<19;i++)
        {
          zancun1[i]=aa[i+139];
          
        }
         break;
        } 
    //获得起始站id
     for(int i=0;i<zancun1.length;i++) {
      if(zancun1[i].equals(a)) {
       qizhanid=i;
       break;
      }
     }
    //获得终站id
      for(int i=0;i<zancun1.length;i++) {
        if(zancun1[i].equals(b)) {
       zhongzhanid=i;
      break;
       }          
                  }
      //判断起站和中站的起始顺序
      if(qizhanid<=zhongzhanid) {
       for(int i=qizhanid;i<=zhongzhanid;i++) {   //起始站在终点站前面
        System.out.println(zancun1[i]);
       }
        }else {
      //在一个路线上直线输出路线
      for(int i=qizhanid;i>=zhongzhanid;i--) {
       System.out.println(zancun1[i]);
      }}
         }         
 }      }
 技术图片

 

 技术图片

 

自己原创线路 有缺陷代码

标签:石家庄   cti   ansi   input   pos   orm   style   width   warnings   

原文地址:https://www.cnblogs.com/yang-qiu/p/10651750.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!