java面试题之编程【火星车问题】_java题nasa排出的一个机器小车分队已经

算法刷题

大厂面试还是很注重算法题的,尤其是字节跳动,算法是问的比较多的,关于算法,推荐《LeetCode》和《算法的乐趣》,这两本我也有电子版,字节跳动、阿里、美团等大厂面试题(含答案+解析)、学习笔记、Xmind思维导图均可以分享给大家学习。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

写在最后

最后,对所以做Java的朋友提几点建议,也是我的个人心得:

  1. 疯狂编程

  2. 学习效果可视化

  3. 写博客

  4. 阅读优秀代码

  5. 心态调整

*author:Kevin
 *date:2011-07-17
 *function:The problem of Mars car.

*China firmly opposes Obama-Dalai meeting
 *The WAR is actually begun!Now you are the Commander of the Fleet.
 *You  can input command to control the Mars Car to go straight,
 *turn left,turn right,and the car maybe your loyal soldier.
 *The command input like this string:LL1LRR89L2,
 *and at last  report the location of the car to Commander.
 *L means turn left,R means turn right,number0-9 means how far the car can go
 *request:1).ExtremeProgramming 2).Pair Programming 3).Test Driven Development
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class TestMarsCar {

public static void main(String[] args) throws Exception {

BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  System.out
    .println(“Now,the Mars car is loarding on the Mars,input the loaction”);
  System.out.println(“input x:(number)”);
  String x = bf.readLine();
  System.out.println(“input y:(number)”);
  String y = bf.readLine();
  System.out.println(“input direction:(N,W,S,E)”);
  String f = bf.readLine();
  System.out.println(“the car is loaded in (” + x + “,” + y + “,” + f
    + “)”);
  // create Marscar object
  Marscar car = new Marscar(x, y, f);

while (true) {
   System.out.println(“\n***********************”
     + “\npress 1or 2 to select *” + “\n1:new command         *”
     + “\n2:exit                *”
     + “\n***********************\ninput number:”);
   Scanner s1 = new Scanner(System.in);
   int ints1 = Integer.parseInt(s1.next());
   if (ints1 == 1) {
    System.out.println(“input new command like (L,R,0-9):”);

Scanner s = new Scanner(System.in);
    String commands = s.next();
    for (int i = 0; i < commands.length(); i++) {
     String command = String.valueOf(commands.charAt(i));

if (command.equals(“L”)) {
      car.turnLeft(car.getF());
     } else if (command.equals(“R”)) {
      car.goRight(car.getF());
     } else {
      int n = Integer.parseInt(command);
      car.goAhead(n);
     }
     // show the location of mars car.
     System.out.println(“the new location is (” + car.getX()
       + “,” + car.getY() + “,” + car.getF() + “)”);

}
   } else if (ints1 == 2) {
    System.exit(0);
   } else {
    System.out.println(“YOu command is Wrong!”);
   }
  }
 }
}

// -----------------------------------------
// class Marscar
class Marscar {
 private String x; // x-coordinate
 private String y; // Y-coordinate
 private String f; // direction

public String getX() {
  return x;
 }

public void setX(String x) {
  this.x = x;
 }

public String getY() {
  return y;
 }

public void setY(String y) {
  this.y = y;
 }

结尾

学习html5、css、javascript这些基础知识,学习的渠道很多,就不多说了,例如,一些其他的优秀博客。但是本人觉得看书也很必要,可以节省很多时间,常见的javascript的书,例如:javascript的高级程序设计,是每位前端工程师必不可少的一本书,边看边用,了解js的一些基本知识,基本上很全面了,如果有时间可以读一些,js性能相关的书籍,以及设计者模式,在实践中都会用的到。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

高级程序设计,是每位前端工程师必不可少的一本书,边看边用,了解js的一些基本知识,基本上很全面了,如果有时间可以读一些,js性能相关的书籍,以及设计者模式,在实践中都会用的到。

html5

  • 25
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值