java小游戏设计问题(有些冗长,麻烦耐心看完!)

该小游戏是为了实现电脑随机出石头,剪刀,或布,然后玩家根据电脑的要求(赢电脑,输电脑,打平),大致思路是客户端发出指令开始游戏,服务器端接收后随机选择,然后发回给客户端,玩家选择后,服务器做出判断对错。现将游戏的服务器端与客户端贴出,现在的问题是当玩家输入自己的判断后,服务器返回的值一直是“回答错误”,求解!

这是 服务器端 的程序
import java.io.*;
import java.net.*;
import java.util.*;

public class gameServer {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    ServerSocket server = null;
    DataOutputStream out=null;
    DataInputStream in=null;
    Socket you =null;
    String s=null,s1=null;
    int w=0,l=0,d=0,b=0;
    int sum=0;
    while(true){
        try{server = new ServerSocket(4351);}
        catch(IOException e1){
            System.out.println("ERRO:"+e1);
            }
        try{
            you=server.accept();
            in=new DataInputStream(you.getInputStream());
            out=new DataOutputStream(you.getOutputStream());
            while(true){
                 int c =0;
                 c=in.readInt();


                 if(c==-1){
                     b=(int)(Math. random()*8);
                     d=b;
                     if(b==0){

                         s="电脑出布,要打平";



                     }
                     else if(b==1){
                         s="电脑出布,要输电脑";

                     }
                     else if(b==2){
                         s="电脑出布,要赢电脑";

                     }
                     else if(b==3){
                         s="电脑出石头,要打平";

                     }
                     else if(b==4){
                         s="电脑出石头,要输电脑";

                     }
                     else if(b==5){
                         s="电脑出石头,要赢电脑";

                     }
                     else if(b==6){
                         s="电脑出剪刀,要打平";

                     }
                     else if(b==7){
                         s="电脑出剪刀,要输电脑";

                     }
                     else {
                         s="电脑出剪刀,要赢电脑";

                     }
                 }
                 System.out.println(s);


            if(c==1){
              if(d==0&&d==5&&d==7&&d==8)
                  s="回答正确!";

              else
                  s="回答错误";




            }
            if(c==0){
              if(d==2&&d==6&&d==4)
                  s="回答正确!";


              else
                  s="回答错误";


            }
           if(c==2){
              if(d==1&&d==3)
                  s="回答正确!";

              else
                  s="回答错误";
       }

           System.out.println(s);   



              out.writeUTF(s);
              //sum=w*3+d;
                       //out.writeUTF(s);
                       //out.writeInt(sum);

        }
        }catch(IOException e){}

    }
}

}

下面是 客户端 的程序

import java.io.*;
import java.net.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.Random;

public class gameClient extends JFrame implements ActionListener{
JButton butj ,buts,butb,butl,butstart;

JPanel panel1,panel2,panel3;
JLabel label,label2;
JTextArea showText;
String s1=null;
int a=0;
int sum1=0;

Socket socket=null;
DataInputStream in=null;
DataOutputStream out=null;


public gameClient() {

    setTitle("郁龑");                 
    setLocation(250, 250);             
    setSize(500, 300);                

    showText=new JTextArea();
    socket=new Socket();

    panel1 =  new JPanel();         
    panel1.setBackground(Color.yellow);     
    butj = new JButton("剪刀"); 
    butb=new JButton("布");
    buts = new JButton("石头");

    butl=new JButton("清除");
    butstart=new JButton("开始游戏");

    butj.addActionListener(this);    
    buts.addActionListener(this);
    butb.addActionListener(this);
    butl.addActionListener(this);
    butstart.addActionListener(this);

    panel1.add(butj);                      
    panel1.add(butb);
    panel1.add(buts);                    

    panel1.add(butl);
    panel1.add(butstart);

    panel2 =  new JPanel();         
    panel2.setBackground(Color.green);     
    label = new JLabel("");
    label2= new JLabel("");
    panel2.add(label);                      
    panel2.add(label2); 

    panel3 =  new JPanel();
    panel3.setBackground(Color.blue);

    panel3.add(showText);


    add(panel1,BorderLayout.SOUTH);       
    add(panel2,BorderLayout.CENTER);                 
    add(panel3,BorderLayout.NORTH);

     try{socket=new Socket("localhost",4351);
     in=new DataInputStream(socket.getInputStream());
     out=new DataOutputStream(socket.getOutputStream());}
     catch(IOException ee){
         System.out.println("无法连接");
     }


}
 public void actionPerformed(ActionEvent e){

     if(e.getSource()==butstart){

         a=-1;



 }
     if(e.getSource()==butj){

         a=0;



 }


     if(e.getSource()==butb){

         a=1;


     }
     if(e.getSource()==buts){


         a=2;



         }
     if(e.getSource()==butl){


        a=3;



         }

    try{ 
     out.writeInt(a);

     s1=in.readUTF();
     //sum1=in.readInt();



    }
 catch(IOException ee){
     System.out.println("无法连接");

 }
    label.setText(s1); 

 }





public static void main(String[] args) {

    gameClient  frame  = new gameClient();   
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    frame.setVisible(true);  


}

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
网页设计,有一段代码太冗长了,求帮忙优化下!!!感激不尽!!!

**在最底下的那一段script代码太冗长了,求帮忙优化下,感激不尽!!!** 以下是己完成的代码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <style> .explain_box{ float:left; padding-top:23px; padding-left:2px; font-family:"宋体";} .explain_nav li{ float:left; height:39px;display:inline; margin:0px 2px} .explain_nav li a{ float:left; width:108px; height:21px; background:#ededed; color:#000000; font-size:14px; padding:6px 0px; text-align:center;} .explain_nav li a.act{ float:left; width:108px; height:25px; background:url(images/new_pro/explain_nav_bg.png) no-repeat; color:#ffffff;} .explain_cont{ float:left; width:675px;border: solid 1px #cf2849; display:block; margin-top:14px;position:relative; display:none;} .explain_cont_left{ float:right; width:109px; background:#ededed; text-align:center; height:100%;display:block; position:absolute; } .explain_cont_right{ float:right; width: 500px;padding: 14px 33px; background:#f9f9f9;} .explain_cont_right h1{ color:#c80a30; font-size:14px;} .explain_cont_right p{ color:#555555; font-size:12px;} .left_img01{ position:absolute; top:50%; left:50%; margin: -21px 0 0 -21px;} </style> <div class="explain_box" style=""> <ul class="explain_nav"> <li ><a id="a_sgff" href="javascript:show(1)">施工方法</a></li> <li ><a id="a_lrhql" href="javascript:show(2)">理论耗漆量</a></li> <li ><a id="a_xs" href="javascript:show(3)">稀 释</a></li> <li ><a id="a_ctsj" href="javascript:show(4)">重涂时间</a></li> <li ><a id="a_sgtj" href="javascript:show(5)">施工条件</a></li> <li style="display:none"><a id="a_bysj" href="javascript:show(6)">保养时间</a></li> <li style=""><a id="a_qx" href="javascript:show(7)">清 洗</a></li> <li style=""><a id="a_cc" href="javascript:show(8)">储 存</a></li> <li style=""><a id="a_tztx" href="javascript:show(9)">涂装体系</a></li> <li style="display:none"><a id="a_yqpd" href="javascript:show(10)">油漆配对</a></li> <li style="display:none"><a id="a_gzsj" href="javascript:show(11)">干燥时间</a></li> <li style="display:none"><a id="a_tzhcl" href="javascript:show(12)">涂装后处理</a></li> <li style="display:none"><a id="a_dccl" href="javascript:show(13)">底材处理</a></li> <li style="display:none"><a id="a_cpggsm" href="javascript:show(14)">产品规格说明</a></li> <li style="display:none"><a id="a_bzsjsm" href="javascript:show(15)">包装升级说明</a></li> </ul></div> <div class="explain_cont" id="sgff"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img01.png" /> </div> </div> <div class="explain_cont_right"> <h1>施工方法</h1> <p>滚涂/刷涂/无气喷涂</p> </div> </div> <div class="explain_cont" id="lrhql"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img02.png" /> </div> </div> <div class="explain_cont_right"> <h1>理论耗漆量</h1> <p>12 平方米/升/单遍(干膜30微米计) 因实际施工表面的粗糙程度和稀释比例不同,耗漆量也有所不同 </p> </div> </div> <div class="explain_cont" id="xs"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img03.png" /> </div> </div> <div class="explain_cont_right"> <h1>稀 释</h1> <p>使用前应搅拌均匀<br> 为达到最佳涂刷效果,滚涂、刷涂时可根据实际情况使用不多于10%(体积比)的清水稀释(可根据施工手感酌情增减)<br> 若使用无气喷涂,可根据实际情况使用不多于5%(体积比)的清水稀释 </p> </div> </div> <div class="explain_cont" id="ctsj"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img04.png" /> </div> </div> <div class="explain_cont_right"> <h1>重涂时间</h1> <p>(以干膜30微米,25~30℃计)<br> 表干:30分钟<br> 硬干:60分钟<br> 重涂:间隔2小时以上 (温度过高或温度略低,应适当延长),但最长在一周内重涂。<br> 如果超过7天没有涂刷面漆,请打磨底漆以保证良好的附着力。 </p> </div> </div> <div class="explain_cont" id="sgtj"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img05.png" /> </div> </div> <div class="explain_cont_right"> <h1>施工条件</h1> <p>请不要在潮湿或寒冷的天气(气温低于5℃,相对湿度大于85%)情况下施工,否则不能达到预期的涂装效果</p> </div> </div> <div class="explain_cont" id="bysj"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img06.png" /> </div> </div> <div class="explain_cont_right"> <h1>保养时间</h1> <p></p> </div> </div> <div class="explain_cont" id="qx"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img07.png" /> </div> </div> <div class="explain_cont_right"> <h1>清 洗</h1> <p>涂装中途停顿及涂装完毕后,请及时使用清水清洗所有器具</p> </div> </div> <div class="explain_cont" id="cc"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img08.png" /> </div> </div> <div class="explain_cont_right"> <h1>储 存</h1> <p>密闭存于0-35℃阴凉干燥处</p> </div> </div> <div class="explain_cont" id="tztx"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img12.png" /> </div> </div> <div class="explain_cont_right"> <h1>涂装体系</h1> <p><p><img alt="" width="544" height="366" src="/res/image/201421411491.jpg" /><!--StartFragment --></p> <div>&nbsp;<img alt="" width="544" height="579" src="/res/image/2014214114952.jpg" /></div> <p><img alt="" width="544" height="83" src="/res/image/201421411509.jpg" /></p></p> </div> </div> <div class="explain_cont" id="yqpd"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img03.png" /> </div> </div> <div class="explain_cont_right"> <h1>油漆配对</h1> <p></p> </div> </div> <div class="explain_cont" id="gzsj"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img04.png" /> </div> </div> <div class="explain_cont_right"> <h1>干燥时间</h1> <p></p> </div> </div> <div class="explain_cont" id="tzhcl"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img11.png" /> </div> </div> <div class="explain_cont_right"> <h1>涂装后处理</h1> <p></p> </div> </div> <div class="explain_cont" id="dccl"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img09.png" /> </div> </div> <div class="explain_cont_right"> <h1>底材处理</h1> <p></p> </div> </div> <div class="explain_cont" id="cpggsm"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img13.png" /> </div> </div> <div class="explain_cont_right"> <h1>产品规格说明</h1> <p></p> </div> </div> <div class="explain_cont" id="bzsjsm"> <div class="explain_cont_left"> <div class="left_img01"> <img src="images/new_pro/icon_img14.png" /> </div> </div> <div class="explain_cont_right"> <h1>包装升级说明</h1> <p></p> </div> </div> <script> function show(val){ var b1 = document.getElementById('sgff'); var b2 = document.getElementById('lrhql'); var b3 = document.getElementById('xs'); var b4 = document.getElementById('ctsj'); var b5 = document.getElementById('sgtj'); var b6 = document.getElementById('bysj'); var b7 = document.getElementById('qx'); var b8 = document.getElementById('cc'); var b9 = document.getElementById('tztx'); var b10 = document.getElementById('yqpd'); var b11 = document.getElementById('gzsj'); var b12 = document.getElementById('tzhcl'); var b13 = document.getElementById('dccl'); var b14 = document.getElementById('cpggsm'); var b15 = document.getElementById('bzsjsm'); var a1 = document.getElementById('a_sgff'); var a2 = document.getElementById('a_lrhql'); var a3 = document.getElementById('a_xs'); var a4= document.getElementById('a_ctsj'); var a5 = document.getElementById('a_sgtj'); var a6 = document.getElementById('a_bysj'); var a7 = document.getElementById('a_qx'); var a8 = document.getElementById('a_cc'); var a9 = document.getElementById('a_tztx'); var a10 = document.getElementById('a_yqpd'); var a11 = document.getElementById('a_gzsj'); var a12 = document.getElementById('a_tzhcl'); var a13 = document.getElementById('a_dccl'); var a14 = document.getElementById('a_cpggsm'); var a15 = document.getElementById('a_bzsjsm'); if (val=="1"){ a1.className='act'; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display='block'; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="2"){ a1.className=''; a2.className='act'; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display='block'; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="3"){ a1.className=''; a2.className=''; a3.className='act'; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display='block'; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="4"){ a1.className=''; a2.className=''; a3.className=''; a4.className='act'; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display='block'; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="5"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className='act'; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display='block'; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="6"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className='act'; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display='block'; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="7"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className='act'; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display='block'; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="8"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className='act'; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display='block'; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="9"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className='act'; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display='block'; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="10"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className='act'; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display='block'; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="11"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className='act'; a12.className=''; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display='block'; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="12"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className='act'; a13.className=''; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display='block'; b13.style.display=''; b14.style.display=''; b15.style.display=''; } else if(val=="13"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className='act'; a14.className=''; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display='block'; b14.style.display=''; b15.style.display=''; } else if(val=="14"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className='act'; a15.className=''; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display='block'; b15.style.display=''; } else if(val=="15"){ a1.className=''; a2.className=''; a3.className=''; a4.className=''; a5.className=''; a6.className=''; a7.className=''; a8.className=''; a9.className=''; a10.className=''; a11.className=''; a12.className=''; a13.className=''; a14.className=''; a15.className='act'; b1.style.display=''; b2.style.display=''; b3.style.display=''; b4.style.display=''; b5.style.display=''; b6.style.display=''; b7.style.display=''; b8.style.display=''; b9.style.display=''; b10.style.display=''; b11.style.display=''; b12.style.display=''; b13.style.display=''; b14.style.display=''; b15.style.display='block'; } } </script>

java实现 循环冗余校验(CRC)算法

算法的要求是如下: ① 装一个16 位寄存器,所有数位均为1。 ② 取被校验串的一个字节与16 位寄存器的高位字节进行“异或”运算。运算结果放 入这个16 位寄存器。 ③ 把这个16 寄存器向右移一位。 ④ 若向右(标记位)移出的数位是1,则生成多项式1010 0000 0000 0001 和这个寄 存器进行“异或”运算;若向右移出的数位是0,则返回③。 ⑤ 重复③和④,直至移出8 位。 ⑥ 取被校验串的下一个字节 ⑦ 重复③~⑥,直至被校验串的所有字节均与16 位寄存器进行“异或”运算,并移位 8 次。 ⑧ 这个16 位寄存器的内容即2 字节CRC 错误校验码。 校验码按照先高字节后低字节的顺序存放。 我自己理解实现了下: ``` public static short crc16(byte[] data) { short crc = (short) 0xFFFF; short dxs = (short) 0xA001; byte tc; byte sbit; for (int i = 0; i < data.length; i++) { tc = (byte) ((crc & 0xff00) >> 8); crc = (short) (tc ^ data[i]); for (int r = 0; r < 8; r++) { sbit = (byte) (crc & 0x01); crc = (short) (crc >> 1); if (sbit != 0) crc = (short) (crc ^ dxs); } } System.out.println(bytesToHexString(new byte[] { (byte) ((crc & 0xff00) >> 8), (byte) (crc & 0xff) })); return crc; } //将字节数组按16进制输出 public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) { return null; } for (int i = 0; i < src.length; i++) { int v = src[i] & 0xFF; String hv = Integer.toHexString(v); if (stringBuilder.length() != 0) { stringBuilder.append(","); } if (hv.length() < 2) { stringBuilder.append(0); } stringBuilder.append(hv); } return stringBuilder.toString(); } ``` 可是我计算出的接口和文档上对不上,不知道哪里有问题?

Java 方法调用,返回arraylist总为空问题

程序代码如下,例如namelist.txt文件里有两行名字为lisa,andy john,ann但是返回值总为空,是方法有问题还是调用有问题?还是返回值的位置问题? 返回arraylist是老师要求的,如果代码冗长繁琐请轻拍。。(不明白为什么粘贴上来这个样子,请见谅) //读取CSV文件,并输出你所要查看的列数的内容 public class CSVParser extends ConsoleProgram { public void run(){ ArrayList<String> result = new ArrayList<String>(); String filename = openfile("Enter the filename :"); int columnIndex = readInt("Enter the column index :"); result = extractColumn(filename,columnIndex); println(result); } //读取文件,若文件不存在则提示,重新键入文件名 private String openfile(String prompt){ BufferedReader rd = null; while(rd==null){ try{ String name = readLine(prompt); rd = new BufferedReader(new FileReader(name)); }catch(IOException e){ println("bad file.The file doesn't exist."); } } return getName(); } //根据文件名和所要获取的列数输出该列所有内容 private ArrayList<String> extractColumn(String filename, int columnIndex) { ArrayList<String> result = new ArrayList<String>(); try { BufferedReader rd = new BufferedReader(new FileReader(filename)); String line=""; while((line = rd.readLine()) != null){ String str = (fieldsIn(line).get(columnIndex-1)); result.add(str); }rd.close(); }catch (IOException e){ e.printStackTrace(); } return result; } //将line中的所有字段都整合到一个ArrayList上 private ArrayList<String> fieldsIn(String line) { ArrayList<String> result = new ArrayList<String>(); int num=0; while(true){ num = line.indexOf(','); if(num<=0){ result.add(line);break; } String str = line.substring(0, num); line = line.substring(num+1); result.add(str); } return result ; } }

关于C++多重继承造成数据冗长问题

C++在继承机制中会产生一些无用的数据, 现在有什么方法可以处理吗?

C语言 智力问答之小球放置问题

在一个10*10*10(mm)的立方体空间中,放置半径大小为0.2-1.2(mm)的球,问: 如何放置,才能使得半径为0.6的小球占总球数的60%以上,且所有小球的体积占整个立方体的60%以上? 提醒:球与球之间最多只能相切,球的体积公式:(4.0/3)PI*r^3 !

在Eclipse 里为新建的java类指定父类不识别

不知道什么原因,在eclipse 建好的工程中,File->New->class 里,填好了子类的名字 在Superclass中指定同一个包里的类作为父类,新建一个子类,但是在子类中引用父类的 公共成员变量和方法,都会报cannot be resolved or is not a field的错误,但是 如果我File->New->class新建一个类,直接写extends 刚刚的那个父类,就不会发生这个问题。 叙述的有些冗长,希望那个好心人帮忙解释下,多谢了

hibernate.cfg.xml过于冗长怎么解决?

现在项目中模块越来越多,hibernate.cfg.xml引入的映射越来越多,配置文件过于冗长,大家是怎样去处理。 或者说如何将hibernate.cfg.xml拆分成若干份。

如何在php中拆分冗长的URI

<div class="post-text" itemprop="text"> <p>I am sending bulk SMS with php API through a SMS gatway like this:</p> <pre><code>http://smsserviceprovider.com/sendsms.php?apikey=xxxx&amp;text=testsms&amp;mobiles=11111,22222,33333,44444,55555,66666.... </code></pre> <p>(upto 1800 mobile numbers which is stored in <code>mysqldb</code>). But the service provider only allow me to send only 50 mobiles at once. So I have to send SMS in multiple times. How can I <code>split the parameter</code>mobiles like this</p> <pre><code>http://smsserviceprovider.com/sendsms.php?apikey=xxxx&amp;text=testsms&amp;mobiles=11111,22222 http://smsserviceprovider.com/sendsms.php?apikey=xxxx&amp;text=testsms&amp;mobiles=33333,44444 http://smsserviceprovider.com/sendsms.php?apikey=xxxx&amp;text=testsms&amp;mobiles=55555,66666.... </code></pre> <p>My current function in php is </p> <pre><code>function send_sms($message, $numbers) { $apikey="xxxxx"; $message=urlencode($message); $var = "apikey=".$apikey."&amp;text=".$message."&amp;mobiles=".$numbers"; $curl=curl_init('http://smsserviceprovider.com/sendsms.php?'.$var); curl_setopt($curl, CURLOPT_RETURNTRANSFER,true); $response=curl_exec($curl); curl_close($curl); return $response; } </code></pre> </div>

Symfony2并避免过于冗长的代码

<div class="post-text" itemprop="text"> <p>In most of my controllers, I need to get a reference to one or more of my custom entity repositories, so naturally, I do this a lot:</p> <pre><code>/** @var $repo MyFirstEntityRepository */ $repo1 = $this-&gt;getDoctrine()-&gt;getManager()-&gt;getRepository('MyNamespaceMyBundle:MyFirstEntity'); /** @var $repo MySecondEntityRepository */ $repo2 = $this-&gt;getDoctrine()-&gt;getManager()-&gt;getRepository('MyNamespaceMyBundle:MySecondEntity'); /** @var $repo MyThirdEntityRepository */ $repo3 = $this-&gt;getDoctrine()-&gt;getManager()-&gt;getRepository('MyNamespaceMyBundle:MyThirdEntity'); </code></pre> <p>My question is: if I have a bunch of different Entities that I need a repository reference for, is it good practice to create a bunch of corresponding <code>get[EntityName]Repository</code> methods in some sort of <code>BaseController</code> which all other controllers could inherit from?</p> <p>The refactored controller code would be more like:</p> <pre><code>$repo1 = $this-&gt;getMyFirstEntityRepository(); $repo2 = $this-&gt;getMySecondEntityRepository(); $repo3 = $this-&gt;getMyThirdEntityRepository(); </code></pre> <p>Which would play nicely with IDE autocompletion and type inference as well.</p> <p>Is this good practice? Or does it violate some sort of standard? Does it make the code any less "loosely coupled"?</p> </div>

Magento - 冗长的自定义选项不保存

<div class="post-text" itemprop="text"> <p>hoping someone can shed some light on this issue.</p> <p>I have a few websites that are experiencing the same issue. </p> <p>I have products which have several custom options and while adding them (up to a certain point) they were adding in fine. It seems that once I get to a certain level of options the website fails to save any more. The website gives the impression that the new options have saved but when I go back in to the product the options are not there.</p> <p>As you can imagine this is fairly frustrating and my obvious point of contact for getting this resolved was with my server host. I have a dedicated server with UKFast (who are usually top notch at getting any issues like this resolved). Problem is they claim it is not a server related issue as there are no errors being thrown up.</p> <p>They have every increased memory limits etc etc for me with no luck.</p> <p>I have found several posts with similar issues, all blaming hosting environment and recommending increasing limits such as this:</p> <pre><code>memory_limit = 1024M upload_max_filesize = 200M post_max_size = 200M max_input_vars = 10000 </code></pre> <p>Which my host has actioned but with no success.</p> <p>Can anyone recommend anything that may get me out of this jam?</p> <p>Any advice would be appreciated.</p> <p>Thanks in advance.</p> </div>

如何管理可搜索的冗长功能列表?

<div class="post-text" itemprop="text"> <p>I hope this doesnt ends up as open ended question. i am not a developer but trying to write a software/utility to help me in my own line of work. I am network engineer and do presales job. I need to write a software that can help me search based on the lengthy list of features spread across multiple switches. Sample is below</p> <p>Cisco-SW1 Vlan 802.1Q PaGP LaCP Dot1x .. trustsec</p> <p>Cisco-SW2 vlan 802.1Q RIP OSPF Dot1x .. BGP</p> <p>Now when i type 802.1q, is should get both switches as result, if i type OSPF, only sw2 should be shown as result. I am not exactly sure if i shall use MySQL or something else? i am not a programmer so i am not updated with latest possible techniques. I cant hire a programmer since i am doing it for my ownself and wont be funded by my company.</p> <p>the list of features could extends to 100s so thats why need a scalable technique.</p> <p>Please dont derate this post, just need an idea</p> </div>

如何在php查询中插入冗长的语句?

<div class="post-text" itemprop="text"> <p>I need to insert a lengthy statement (see below) into a query.</p> <pre><code>$q = 'SELECT vh12915_fleet.systemHistory.systName, vh12915_space.stars.x, vh12915_space.stars.y FROM vh12915_fleet.systemHistory INNER JOIN vh12915_space.stars ON vh12915_fleet.systemHistory.systName = vh12915_space.stars.name WHERE vh12915_fleet.systemHistory.fleetName = "Fl"'; </code></pre> <p>The statement I provided is error-free, as it has been tested in phpMyadmin and worked.</p> <p>However, when put into a script it produces an error.</p> <p>What is the right way to put a lengthy statement into a query? Why does this exact statement work in phpMyAdmin, and not in the script?</p> </div>

处理冗长脚本时的php-capture控制台输出

<div class="post-text" itemprop="text"> <p>I have an issue on capturing the ssh script output onto the browser as it executes rather than having it in the end.</p> <p>Script written:</p> <pre><code>$descriptorspec = array( 0 =&gt; array("pipe","r"), 1 =&gt; array("pipe","w"), 2 =&gt; array("file","./error.log","a") ) ; $cwd = 'path/path1' ; for($counter=1;$counter&lt;= 10;$counter++) { $cmd="sudo test.sh arg1 arg2 arg3"; $process = proc_open('ssh user@server', $descriptorspec, $pipes, $cwd) ; if (is_resource($process)) { fwrite($pipes[0], $cmd) ; fclose($pipes[0]) ; echo stream_get_contents($pipes[1]) ; fclose($pipes[1]) ; $return_value = proc_close($process); echo "$counter=command returned $return_value&lt;br&gt;"; } } </code></pre> <p>Shell script takes 10mins to execute. If the $counter=10 then it taking too much time to get the real output thrown on screen. I require that it keeping on showing the stream output as it executes so that we know what's happening. Is there case of buffering?</p> </div>

PHP使用冗长的循环创建不稳定的服务器错误

<div class="post-text" itemprop="text"> <p>I have a PHP script that pulls down a bunch of RSS feeds. To prevent overloading the publishers' servers, I use the PHP Sleep function to slow things down.</p> <p>The entire script could last for a couple of hours.</p> <p>If I run this from a Cron job on GoDaddy, it will happily work for 5 - 10 minutes and then return a server error. I checked and the PHP maximum execution time is 30 seconds, so I'm not sure if this is the cause of the problem.</p> <p>If I run the job on my Mac, my local PHP also has a default maximum execution time of 30 seconds, but this script does work if I run it from the terminal, but I don't understand why.</p> <p>How do I loop a script that will exceed 30 seconds without running into unreliability problems?</p> <p>Help appreciated.</p> </div>

在php中优化和美化冗长而丑陋的SQL查询

<div class="post-text" itemprop="text"> <p>Im beginner in php and i have problem with sql string optimization and beauty.</p> <pre><code>$kiti_neplp = mysql_query("SELECT (SELECT coalesce(SUM(skaicius)*6, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V3') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V4') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V7') +(SELECT coalesce(SUM(skaicius)*8, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V9') +(SELECT coalesce(SUM(skaicius)*0.3, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V11') +(SELECT coalesce(SUM(skaicius)*0.3, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V13') +(SELECT coalesce(SUM(skaicius)*16, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V14') +(SELECT coalesce(SUM(skaicius)*8, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V16') +(SELECT coalesce(SUM(skaicius)*8, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V17') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V18') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V19') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V21') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V22') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V23') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V24') +(SELECT coalesce(SUM(skaicius)*3, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V51') +(SELECT coalesce(SUM(skaicius)*4, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V52') +(SELECT coalesce(SUM(skaicius)*16, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V34') +(SELECT coalesce(SUM(skaicius)*16, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V35') +(SELECT coalesce(SUM(skaicius)*8, 0) FROM menesiai WHERE metai = '".$metaiat."' {$SQLmenuo} {$SQLskyrius} AND rdkodas = 'V36') as kiti_neplp"); </code></pre> <p>Im building sql query string but it looks realy ugly. Is it a better way to build that long and ugly query? Because now im writing 10 almost the same strings (with different coefficients and rdkodas). Of course I can write it and it works good for me, but i want to learn how to do this in a good way. Thank you for understanding</p> </div>

PHP:立即返回响应,但在后台运行多个冗长的shell_exec函数

<div class="post-text" itemprop="text"> <p>I am creating a simple web service that accepts a video upload, runs multiple different encodes on the video (mp4, webm, ogv), and then uploads the newly created files to our video host.</p> <p>Let's say I have multiple commands..</p> <pre><code>shell_exec('ffmpeg -i input.mp4 -f mp4 -c:v libx264 -preset slow -crf 24 -s 1280x720 -c:a libfdk_aac -profile:a aac_he -ar 22050 -b:a 64k -movflags +faststart output-1280x720.mp4'); shell_exec('ffmpeg -i input.mp4 -f mp4 -c:v libx264 -preset slow -crf 24 -s 1920x1080 -c:a libfdk_aac -profile:a aac_he -ar 22050 -b:a 64k -movflags +faststart output-1920x1080.mp4'); shell_exec('ffmpeg -i input.mp4 -f ogg -c:v libtheora -q:v 5 -s 1280x720 -c:a libvorbis -ar 22050 -b:a 64k -movflags +faststart output-1280x720.ogv'); shell_exec('ffmpeg -i input.mp4 -f ogg -c:v libtheora -q:v 5 -s 1920x1080 -c:a libvorbis -ar 22050 -b:a 64k -movflags +faststart output-1920x1080.ogv'); </code></pre> <p>In summary, I want to...</p> <ol> <li>Print an immediate response: {success: true}</li> <li>Kick off multiple ffmpeg jobs synchronously.</li> <li>After each job is complete, send a POST to another server (one POST for each shell_exec).</li> </ol> <p>It would also be nice to only send the POST if the job was successful, but I could easily work around that by just checking to see if the output file exists on the server.</p> <p>I know that I can force shell_exec to run in the background by simply appending <code>&gt;/dev/null 2&gt;/dev/null &amp;</code> to each command -- which would allow me to print a response immediately -- but I think by doing this, this would cause all of the jobs to run in parallel, and also, since this is diverting the output, I do not get any true callbacks when jobs are complete.</p> <p>Any ideas??</p> </div>

什么是使日志记录更少冗长的正确方法(chromedp)?

<div class="post-text" itemprop="text"> <p>My question is this package-specific: <a href="https://github.com/knq/chromedp/" rel="nofollow noreferrer">https://github.com/knq/chromedp/</a></p> <p>This is just a glimpse of a log when running <strong>chromedp</strong> <code>Action</code>s. It is not event an Action-related piece. What is the correct way to make the logging silent or less verbose?</p> <p><a href="https://i.stack.imgur.com/2v4N9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2v4N9.png" alt="enter image description here"></a></p> </div>

在golang中定义为常数的结构的受限值时,如何降低冗长性?

<div class="post-text" itemprop="text"> <p>Suppose I have the following snippet in my package:</p> <pre><code>package fruits type fruitType uint8 const( banana fruitType = iota apple fruitType = iota strawberry fruitType = iota ) type allFruitTypes struct { Banana fruitType Apple fruitType Strawberry fruitType } var allFruitTypesImpl = allFruitTypes { Banana: banana, Apple: apple, Strawberry: strawberry, } //GetAllFruitTypes returns a list with all the possible fruit types func GetAllFruitTypes() *allFruitTypes { return &amp;allFruitTypesImpl } </code></pre> <p>In this way, I can avoid that outside my package new types of fruits are created. And still it allows to read my list of possible fruit types. Is that correct?</p> <p>So my main problem in here is that I find really annoying to define 3 things that mean the same:</p> <ol> <li>the consts using iota</li> <li>the declaration of the struct type</li> <li>defining the struct implementation and typing in the values for each member.</li> </ol> <p>For me, semantically the three of them mean the same. However, because of the way go works (or my lack of knowledge on how to type this better in go) I have to retype the same thing 3 times.</p> <p>Is there any way to cause the same effect without having to type down the very same semantics 3 times?</p> </div>

是否有任何Docker PHP图像没有冗长的编译过程,或者如何减少编译量,以加快图像构建?

<div class="post-text" itemprop="text"> <p>I am using one of the official Docker PHP images (7.1 Stretch) at <a href="https://github.com/docker-library/php/blob/74b59e1cf7e5a356b5d4ee5eaeffe5f70f5ebd4c/7.1/stretch/cli/Dockerfile" rel="nofollow noreferrer">https://github.com/docker-library/php/blob/74b59e1cf7e5a356b5d4ee5eaeffe5f70f5ebd4c/7.1/stretch/cli/Dockerfile</a></p> <p>Building this image (a full clean build) has a lengthy compilation process. Is there any way to avoid or minimize this lengthy process? For example, is there a PHP image that pulls binary packages rather than source code packages (which require compilation)?</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐