急求大神帮忙解决的问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/ltyqljhwcm/article/details/51385616

上一篇的动态规划入门题我引申了几个问题不会解决求大神帮忙

1:如何判断对于给定的硬币的种类对某个特定的值不存在任何一个可以满足的情况

2:如何将所有可能的凑出来的情况都进行保存

展开阅读全文

大神帮忙解决

02-24

import java.io.*;rnpublic class Calculator rn // 定义相关变量rn private String sum = null;rn private String qbrc = null;rn private double qbr1 = 1;rn private double qbr2 = 1;rn String abr1;rn String abr2;rn public Calculator()rn rn rn public void sumT()rn /*rn * 接口功能:进行相关的输入和类型转换 rn * 接口输入:空 rn * 接口输出:空 rn */rn tryrn System.out.println("欢迎使用!!!/n此计算器除可以进行数字各种相关运算还可以进行字符串的相加");rn System.out.print("请您输入您的第一次输入:");rn BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));rn System.out.print("请输入您的第二次输入:");rn BufferedReader br2 = new BufferedReader(new InputStreamReader(System.in));rn System.out.print("请选择符号(+、—、*、/):");rn BufferedReader brc = new BufferedReader(new InputStreamReader(System.in));rn qbrc = brc.toString();rn abr1 = br1.toString();rn abr2 = br2.toString();rn catch(Exception e)rn e.printStackTrace();rn System.err.println("操作有误,请重新操作!!!");rn rn tryrn qbr1 = Double.parseDouble(abr1);rn qbr2 = Double.parseDouble(abr2);rn rn rn catch(Exception e)rn e.printStackTrace();rn System.err.println("***"+abr1+abr2+"***");rn rn /*rn * 接口功能:进行相关运算并输出结果 rn * 接口输入:空 rn * 接口输出:空 rn */rn tryrn if(qbrc=="+")rn double resultOf = qbr1+qbr2;rn System.out.println("第一个数:"+abr1+"\n第二个数:"+abr2+"\n结果为:"+resultOf);rn rn if(qbrc=="-")rn double resultOf = qbr1-qbr2;rn System.out.println("第一个数:"+abr1+"\n第二个数:"+abr2+"\n结果为:"+resultOf);rn rn if(qbrc=="*")rn double resultOf = qbr1*qbr2;rn System.out.println("第一个数:"+abr1+"\n第二个数:"+abr2+"\n结果为:"+resultOf);rn rn if(qbrc=="/")rn double resultOf = qbr1/qbr2;rn System.out.println("第一个数:"+abr1+"\n第二个数:"+abr2+"\n结果为:"+resultOf);rn rn catch(Exception e)rn e.printStackTrace();rn System.err.println("**********\n您的除数不能为零!!!\n**********");rn rn rn rn rn /**rn * @param argsrn */rn public static void main(String[] args) rn Calculator calculator = new Calculator();rn calculator.sumT();rn rnrnrn 论坛

急求大神解决

07-23

编译之后出现以下问题,急求大神解决rnfatal error C1083: Cannot open include file: 'save': No such file or directoryrn执行 cl.exe 时出错.rnrn程序:rn#includern#includern#define MVNum 100rn#define Maxint 32767rnenum booleanFALSE,TRUE;rntypedef char VertexType;rntypedef int Adjmatrix;rntypedef structrnrn VertexType vexs[MVNum];rn Adjmatrix arcs[MVNum][MVNum];rnMGraph;rnrnint D1[MVNum],P1[MVNum];rnint D[MVNum][MVNum],P[MVNum][MVNum];rnrn#include"save"rn#include"djstl"rn#include"floyd"rnrnvoid main()rnrn MGraph *G;rn int m,n,e,v,w,k;rn int xz=1;rn G=(MGraph *)malloc(sizeof(MGraph));rn printf("输入交通图中城市个数和路径数n,e:");rn scanf("%d,%d",&n,&e);rn CreateMGraph(G,n,e);rn while(xz!=0)rn rn printf("*******求城市之间的最短路径*******");rn printf("==================================\n");rn printf("1.求一个城市到所有城市的最短路径\n");rn printf("2.求任意的两个城市之间的最短路径\n");rn printf("==================================\n");rn printf(" 请选择: 1或2,选择0 退出:");rn scanf("%d",&xz);rn if(xz==2)rn rn Floyd(G,n);rn printf("输入源点(或称起点)和终点:v,w:");rn scanf("%d,%d",&v,&w);rn k=P[v][w];rn if(k==0)rn printf("顶点%d到%d无路径!\n",v,w);rn elsern rn printf("从顶点%d到%d的最短路径是:%d",v,w,v);rn while(k!=w)rn rn printf("——>%d",k);rn k=P[k][w];rn rn printf("——>%d",w);rn printf(" 路径长度:%d\n",D[v][w]);rn rn rn elsern if(xz==1)rn rn printf("求单源路径,输入源点v:");rn scanf("%d",&v);rn Dijkstra(G,v,n);rn rn rn printf("结束求最短路径!\n");rnrnrnvoid CreateMGraph(MGraph *G,int n,int e)rnrn int i,j,k,w;rn for(i=1;i<=n;i++)rn G->vexs[i]=(char)i;rn for(i=1;i<=n;i++)rn for(i=1;j<=n;j++)rn G->arcs[i][j]=Maxint; //初始化邻接矩阵rn printf("输入%d条边的i,j及w:\n",e);rn for(k=1;k<=e;k++)rn rn scanf("%d,%d,%d",&i,&j,&w);rn G->arcs[i][j]=w;rn rn printf("交通网络图的存储结构建立完毕!\n"); rnrnrnvoid Dijkstra(MGraph *G,int vl,int n)rnrn int D2[MVNum],P2[MVNum];rn int v,i,w,min;rn enum boolean S[MVNum];rn for(v=1;v<=n;v++)rn rn S[v]=FALSE;rn D2[v]=G->arcs[vl][v];rn if(D2[v]arcs[v][w]arcs[v][w];rn P2[w]=v;rn rn rn printf("路径长度 路径\n");rn for(i=1;i<=n;i++)rn rn printf("%5d",D2[i]);rn printf("%5d",i);rn v=P2[i];rn while(v!=0)rn rn printf("<-&d",v);rn v=P2[v];rn rn printf("\n");rn rnrnrnvoid Floyd(MGraph *G,int n)rnrn int i,j,k,w,v;rn for(i=1;i<=n;i++)rn for(j=1;j<=n;j++)rn rn if(G->arcs[i][j]!=Maxint)rn P[i][j]=j;rn elsern P[i][j]=0;rn D[i][j]=G->arcs[i][j];rn rn for(k=1;k<=n;k++)rn rn for(j=1;j<=n;j++)rn rn if(D[i][k]+D[k][j] 论坛

急求大神帮忙!!!急!!!

12-28

编写一个C++学生成绩管理系统,能完成对10个学生成绩进行处理的相关功能。功能包括输入学生成绩、显示学生成绩、查找某一成绩、输出最高成绩、插入一个成绩、排序、退出程序等。n具体运行界面如下:n1.欢迎及相关功能选择界面n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281711_136954.png)n2.确定功能选择的界面n当输入1时,出现询问是否确定选择此功能。n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281762_185736.png)n当输入N时,出现如下界面,再次输入选择的功能编号。n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281774_845383.png)n如果输入其他功能时,都与输入1类似。当输入Y时,进入相关功能界面n3. 相关功能界面n(1)1输入功能界面n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281792_903665.png)n输入成绩后,如下n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281805_216775.png)n(2)2显示界面n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281818_144999.png)n(3)查找功能n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281839_776330.png)n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281850_670178.png)n第几个成绩参看排序后的位置n(4)最高成绩功能n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281861_701726.png)n(5)插入功能n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281873_542423.png)n插入成功后,选择2显示功能如下:n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281886_38704.png)n(6)排序功能(从高到低排序)n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281897_348801.png)n排序后,输入2显示功能,如下n![图片说明](https://img-ask.csdn.net/upload/201512/28/1451281918_8757.png) 问答

急求大神帮忙!急!!!!!!!!

09-02

MouseListener没有响应,不知道为什么,求大神帮帮忙,看哪不对啊[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]rn[code=java]import java.awt.BorderLayout;rnimport java.awt.event.*;rnimport javax.swing.*;rnrnpublic class MouseTrack implements MouseListenerrn private JFrame myFrame;rn private JTextArea textArea;rn rn public MouseTrack()rn myFrame=new JFrame();rn rn JTextArea textArea=new JTextArea();rn textArea.setEditable(false);rn JScrollPane scroll=new JScrollPane(textArea);rn scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);rn scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);rn rn myFrame.addMouseListener(this);rn rn myFrame.add(scroll,BorderLayout.CENTER);rn rn myFrame.setSize(600,400);rn myFrame.setResizable(false);rn myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn myFrame.setVisible(true);rn rn rn public static void main(String args[])rn MouseTrack frame=new MouseTrack();rn rn rn public void mouseClicked(MouseEvent e) rn System.out.println("***");rn String button;rn if(e.getButton()==e.BUTTON1)rn button="左键";rn rn else if(e.getButton()==e.BUTTON3)rn button="右键";rn rn elsern button="滚轮";rn rn textArea.append("点击了"+button);rn textArea.append("\n点击相对位置:x="+e.getX()+" y="+e.getY());rn textArea.append("点击次数:"+e.getClickCount());rn rn rn public void mousePressed(MouseEvent e)rn public void mouseReleased(MouseEvent e)rn public void mouseEntered(MouseEvent e)rn public void mouseExited(MouseEvent e) ;rnrn[/code] 论坛

大神帮忙解决异常问题

05-27

ERROR: HHH000319: Could not get database metadatarnorg.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))rn at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)rn at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)rn at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)rn at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)rn at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)rn at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:219)rn at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)rn at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:509)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)rn at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242)rn at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372)rn at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:589)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)rn at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)rn at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)rn at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)rn at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)rn at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)rn at java.util.concurrent.FutureTask.run(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn at java.lang.Thread.run(Unknown Source)rn 论坛

大神帮忙解决调用函数问题

07-26

我在用java写学生成绩管理系统,现在遇到一个问题,就是事件监听器在传事件的时候没办法传过去,我写了三个java文件,在同一个包里。rn这是主函数的java文件代码:rn[code=java]rnpackage ManageSystem;rnrnpublic class ManageSystem rn public static void main(String[] args) rn MSFrame frame=new MSFrame("学生成绩管理系统");rn frame.setVisible(true);rn rnrn[/code]rnrnrn这是MSFrame的代码,第二个java文件的代码:rn[code=java]rnpackage ManageSystem;rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rnrnclass MSFrame extends JFramern JLabel label,lblUser,lblPassword;rn JTextField tfUser,tfPassword;rn JButton btnLogin;rn public MSFrame(String s)rn //创建系统登陆界面rn super(s);rn label=new JLabel("南京晓庄学院学生成绩管理系统");rn lblUser=new JLabel("User:");rn lblPassword=new JLabel("Password:");rn tfUser=new JTextField(10);rn tfPassword=new JTextField(20);rn btnLogin=new JButton("Login");rn rn Listener bm=new Listener();rn btnLogin.setBackground(new Color(204,204,255));rn rn //布局rn Box box=Box.createVerticalBox(); rn box.add(label);rn Box bh1=Box.createHorizontalBox(); //用户名Userrn bh1.add(lblUser);rn bh1.add(Box.createHorizontalStrut(8));rn bh1.add(tfUser);rn box.add(bh1);rn box.add(Box.createVerticalStrut(8));rn Box bh2=Box.createHorizontalBox(); //密码Passwordrn bh2.add(lblPassword);rn bh2.add(Box.createHorizontalStrut(10));rn bh2.add(tfPassword);rn box.add(bh2);rn box.add(Box.createVerticalStrut(8));rn box.add(btnLogin);rn box.add(Box.createVerticalStrut(8));rn rn this.add(box);rn this.setBounds(250,250,480,300);rn this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn rn rn btnLogin.addActionListener(bm);rn rn rnrn[/code]rnrnrn这是事件监听器的代码,第三个java文件的代码:rn[code=java]rnpackage ManageSystem;rnrnimport java.awt.event.*;rnrnpublic class Listener implements ActionListenerrn rn @Overridern public void actionPerformed(ActionEvent e) rn String User="iamthemanager";rn String Password="iamthemanager";rn String getUser=bm.tfUser.getText();rn rnrn[/code]rnrnrn问题在这:btnLogin.addActionListener(bm);rnbm这个变量传到事件监听器的时候,就是到这句话“String getUser=bm.tfUser.getText();”的时候,说无法解析bm,我没办法从文本中得到文本框的内容,求详细的解决办法,不要太简短,小弟理解能力比较差。谢谢大神了 论坛

求JAVA大神帮忙解决下这个问题

04-22

鄙人做了个坦克大战的小游戏,相信很多大神们都做过,但是鄙人的炮筒就是显示不出来...求好心人指点,本人学生新手,就这点分了,全拿出来了。rn1,目前共三个class文件,分别为TankClient,Tank,Missile....rn2,疑问所在:我的drawLine()画不出直线。。。rn3,疑问来源: case D: rnSystem.out.println("炮筒方向开始调用--下!"); rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x+Tank.TKLENGTH/2,y+Tank.TKWIDTH ); //就是画不出来! rnSystem.out.println("炮筒方向调用结束--下!");rn3.11简要说明:dir坦克当前方向。PTdir炮筒当前方向。fire()开火,setlocation()调整当前方向。命名做到见名知意。 rnrn4,原先的3个文件的代码:rn ①TankClient类:rnimport java.awt.*;rnimport java.awt.event.*;rnrnpublic class TankClient extends Frame rn rn Tank mytank=new Tank(50,50,this);rn Missile mis=null;rn rn public void paint(Graphics g) rn mytank.drawTank(g);rn if(mis!=null) mis.drawMissile(g);rn rn rn rn public void launchFrame()rn this.setLocation(40, 30);rn this.setSize(800, 600);rn this.setVisible(true);rn this.setResizable(false);rn this.setBackground(Color.green);rn this.addWindowListener(new WindowAdapter()rn rn public void windowClosing(WindowEvent e) rn System.exit(0);rn rn ); rn this.addKeyListener(new KeyMoniter());rn new Thread(new PaintThread()).start();rn rn rn rn public static void main(String[] args) rn TankClient tc =new TankClient();rn tc.launchFrame(); rn rn rn rn private class PaintThread implements Runnablern rn public void run() rn rn while(true)rn repaint();rn try rn Thread.sleep(35);rn catch (InterruptedException e) rn rn e.printStackTrace();rn rn rn rn rn rn rn private class KeyMoniter extends KeyAdapter rn rnrn public void keyPressed(KeyEvent e) rn mytank.keyPressed(e);rn //mis.keyPressed(e);rn rn rn public void keyReleased(KeyEvent e) rn mytank.keyReleased(e);rn rn rnrnrn②Tank类rnimport java.awt.Color;rnimport java.awt.Graphics;rnimport java.awt.event.KeyEvent;rnrnrnpublic class Tank rn private int x,y;rn public static final int XSPEED=5,YSPEED=5;rn public static final int TKLENGTH=30,TKWIDTH=30;rn private boolean BL,BR,BU,BD;rn TankClient tc;rn rn enum DirectionU,D,L,R,LU,RU,RD,LD,STOP; rn rn private Direction dir=Direction.STOP; rn Direction PTdir=Direction.D;rn rn public Tank(int x,int y) rn this.x=x;this.y=y;rn rn public Tank(int x,int y,TankClient tc)rn this.x=x;this.y=y;rn this.tc=tc;rn rn rn Missile fire()rn int x=this.x+Tank.TKLENGTH/2;rn int y=this.y+Tank.TKWIDTH/2;rn Missile mis=new Missile(x,y,PTdir);rn return mis;rn rn rn rn public void drawTank(Graphics g)rn rn Color c=g.getColor();rn g.setColor(Color.red);rn g.fillOval(x, y, TKLENGTH, TKWIDTH);rn g.setColor(c); rn rn//System.out.println("炮筒方向开始调用");rng.drawLine(x+Tank.TKLENGTH/2,y+Tank.TKWIDTH/2,x+Tank.TKLENGTH/2,y+Tank.TKWIDTH );rn//g.setColor(Color.black);rn switch(PTdir) rn case U: rn g.drawLine(x+Tank.TKLENGTH/2,y+Tank.TKWIDTH/2,x+Tank.TKLENGTH/2,y);rnSystem.out.println("炮筒方向开始调用--上!"); rn break;rn case D: rnSystem.out.println("炮筒方向开始调用--下!"); rng.setColor(Color.black);rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x+Tank.TKLENGTH/2,y+Tank.TKWIDTH );rn rnSystem.out.println("炮筒方向调用结束--下!"); rn break;rn case L: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x,y+Tank.TKWIDTH/2 );rn rn break;rn case R: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x+Tank.TKLENGTH,y+Tank.TKWIDTH/2 );rn rn break;rn case LU: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x,y);rn break;rn case RU: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x+Tank.TKLENGTH,y );rn break;rn case RD: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x+Tank.TKLENGTH,y+Tank.TKWIDTH );rn break;rn case LD: rn g.drawLine(x+Tank.TKLENGTH/2, y+Tank.TKWIDTH/2, x,y+Tank.TKWIDTH); rn break; rn rn move();rnrn rn rn void move()rn rn switch(dir) rn rn case U: y-=XSPEED;rn break;rn case D: y+=XSPEED;rn break;rn case L: x-=XSPEED;rn break;rn case R: x+=XSPEED;rn break;rn case LU: x-=XSPEED;rn y-=XSPEED;rn break;rn case RU: x+=XSPEED;rn y-=XSPEED;rn break;rn case RD: x+=XSPEED;rn y+=XSPEED;rn break;rn case LD: x-=XSPEED;rn y+=XSPEED; rn break; rn case STOP:rn break;rn rn rn if(this.PTdir!=Direction.STOP) rn this.PTdir=this.dir;rnSystem.out.println("坦克移动方向为子弹射出方向!");rn rn rn rn public void keyPressed(KeyEvent e) rn int key=e.getKeyCode();rn switch(key)rn case KeyEvent.VK_RIGHT:rn BR=true;rn break;rn rn case KeyEvent.VK_LEFT:rn BL=true;rn break;rn rn case KeyEvent.VK_UP:rn BU=true;rn break;rn rn case KeyEvent.VK_DOWN:rn BD=true;rn break;rn case KeyEvent.VK_SPACE:rn tc.mis=fire();rn break;rn rn setLocation();rn//System.out.println(".........KeyPressed()");rn rn rn public void keyReleased(KeyEvent e) rn int key=e.getKeyCode();rn if(key==KeyEvent.VK_RIGHT)rn BR=false;rn rn if(key==KeyEvent.VK_LEFT)rn BL=false;rn rn if(key==KeyEvent.VK_UP)rn BU=false;rn rn if(key==KeyEvent.VK_DOWN)rn BD=false;rn rn rn setLocation();rn rn rn void setLocation()rn if(!BL && !BR && !BU && !BD) dir=Direction.STOP;rn else if( BL && !BR && !BU && !BD) dir=Direction.L;rn else if(!BL && BR && !BU && !BD) dir=Direction.R;rn else if(!BL && !BR && BU && !BD) dir=Direction.U;rn else if(!BL && !BR && !BU && BD) dir=Direction.D;rn else if(BL && !BR && BU && !BD) dir=Direction.LU;rn else if(BL && !BR && !BU && BD) dir=Direction.LD;rn else if(!BL && BR && BU && !BD) dir=Direction.RU;rn else if(!BL && BR && !BU && BD) dir=Direction.RD;rn//System.out.println("setLocation() 可用"); rn rn rn rn rnrnrn③Missile类:rnimport java.awt.Color;rnimport java.awt.Graphics;rnimport java.awt.event.KeyEvent;rnrnrnpublic class Missile rn int x,y; Tank.Direction dir;rn private static final int XSPEED=10;rn private static final int YSPEED=10;rn public static final int LENGTH=10;rnpublic static final int WIDTH=10;rn rnpublic Missile(int x,int y,Tank.Direction dir) rn this.x=x; this.y=y;this.dir=dir;rn rn public void drawMissile(Graphics g)rn//System.out.println("子弹drawMissile()开始调用!"); rn Color c=g.getColor();rn g.setColor(Color.black);rn g.fillOval(x, y, LENGTH, WIDTH);rn g.setColor(c); rn move();rn//System.out.println("子弹drawMissile()调用结束!");rnrn rn void move()rn//System.out.println("子弹move()开始调用!"); rn switch(dir) rn rn case U: y-=XSPEED;rn//System.out.println("子弹移动开始调用--上!"); rn break;rn case D: y+=XSPEED;rn break;rn case L: x-=XSPEED;rn break;rn case R: x+=XSPEED;rn break;rn case LU: x-=XSPEED;rn y-=XSPEED;rn break;rn case RU: x+=XSPEED;rn y-=XSPEED;rn break;rn case RD: x+=XSPEED;rn y+=XSPEED;rn break;rn case LD: x-=XSPEED;rn y+=XSPEED; rn break; rn rn rn//System.out.println("子弹move()调用结束!"); rn rn rn 论坛

急急急 求大神帮忙

01-04

我做的是一个猜数字小游戏 但是在输出前五名记录的时候运行是错的 求大神帮我看看啊 很急很急 明天就要交了 小女子感激不尽 [img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/49.gif][/img]rnrn#includern#includern#includern#includern#includern#includern#include rnrnusing namespace std;rnrnrnconst int max=100;rnvoid instruction();rnvoid start();rnvoid playrecord(char *filename);rnvoid CreateFile2(char *filename); rnvoid Topfive(); rnvoid Topfiverefer(char *filename);rnrnrnclass player //定义一个玩家类,记录玩家的排名、姓名以及成绩rn rnpublic:rn char name[20];rn float score;rn int rank;rnrn rn player(char *a=" ",float b=0, int c=0) rn rn strcpy(name,a); rn score=b;rn rank=c;rnrn rn rn void Setname(char *a=" ") rn rn strcpy(name,a); rn rn void Setscore(float b)rn rn score=b;rn rn void Setrank(int c)rn rn rank=c;rn rn rnrnpl[1000];rnrnstatic int x; //定义一个静态的全局变量rnrnrnvoid CreateFile1(char *filename)//新建一个文本文件存放所有猜出单词的玩家记录?rnrn x++;rn ofstream outf(filename,ios::app);rn cout<<"请输入您的姓名以便记录和查询您的成绩成绩: "; rn cin>>pl[x].name;rn outf<pl[i].score)rn rn yy=pl[i];rn pl[i]=pl[j];rn pl[j]=yy;rn rn rn rn rn for(i=0;i>n;rn switch (n)rn rn case 1: instruction();rn break;rn case 2: start();rn break;rn case 3: playrecord("playrecord.txt");rn break;rn case 4: Topfive();rn break;rn case 5: exit(0);rn break;rn rn rnrnrnrnrnrnvoid instruction()rnrn system("cls");rn cout<<"*********************************欢迎您体验本游戏*******************************"<>number;rn rn while(number!=i)rn rn times++;rn if(number>i)rn cout<<"大了!";rn elsern if(number>number;rn rn rn cout<<"(计时结束)"; //计时结束rn te=time(NULL);rnrn times++;rnrnrn cout<<"恭喜您,猜对了!`(*∩_∩*)′"<>c;rn if (c=='y')rn rn rn system("cls");rn goto mark1;rn rn CreateFile1("playrecord.txt");rn cout<<"按任意键返回主目录"< 论坛

急,求大神帮忙解决一个ajax的问题

01-06

我最近学习java时接触到了ajax,于是想用ajax实现在我的网页上实现一个小功能,可是不知道为什么,网页总是没反应,我试了下,初步估计是没收到服务端页面的回应,求大神帮瞎忙。rn[code=java]<%@ page language="java" import="java.util.*, java.sql.*, com.jm.gy.*" pageEncoding="GB18030"%>rn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rn%>rnrnrnrn rn rn rn 电脑详细信息rn rn rn rn rn rn rn rn rn rn rn rn rn 电脑信息详情rn rn rn 请选择要查询的部门:rn rn 全部单位rn 5rn 6rn rn rn rn 客户信息将在此处列出 ... rn rn rn 添加新电脑 rn rnrn[/code]rn这是我客户页面代码,我试了下调用javascript函数是正常的,就是没法获取服务页面返回的内容。下面是我做的简单的用来测试的服务页面代码:rn[code=java]<%@ page language="java" import="java.util.*, java.sql.*, com.jm.gy.*" pageEncoding="GB18030"%>rn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rn%>rn<%rnresponse.setContentType("text/html;charset=gbk");rnresponse.setHeader("Cache-Control", "no-store"); //HTTP1.1rnresponse.setHeader("Pragma", "no-cache"); //HTTP1.0rnresponse.setDateHeader("Expires", 0); //prevents catching at proxy serverrnrnresponse.getWriter().write("你好");rn%>rn[/code]rn本人刚接触ajax结果卡在这几天了,急啊!求好心的大神帮帮忙 论坛

没有更多推荐了,返回首页