zoukankan      html  css  js  c++  java
  • Lesson_3 上课笔记

     1 import java.util.Iterator;
     2 import java.util.Scanner;
     3 
     4 public class Day3 {
     5 
     6     // eclipse的一些快捷键:
     7     // alt + / 自动提示键
     8     // ctrl + / 注释当前或选择行
     9     // ctrl + d 删除当前行或选择行
    10     // alt + 上下方向键 上下移动行
    11     // ctrl + shift + f 格式化代码
    12     // ctrl + o 查看当前类的结构
    13 
    14     public static void main(String[] args) {
    15         Scanner sc = new Scanner(System.in);
    16         int sum = 0;
    17         // 体育课跑步。
    18         // for(int i = 1 ; i<=100000; i++){
    19         // if(i%5==1 && i%6==5 && i%7==4 && i%11==10){
    20         // System.out.println(i);
    21         // }
    22         // }
    23         
    24         for (int i = 1; i < 25; i++) {// 表示人
    25             for (int j = 1; j <= i; j++) {
    26                 System.out.println("跑" + j + "圈");
    27             }
    28         }
    29         for(int i=1;i<128;i++){//ASCII
    30             System.out.print(i+":" + (char)i + "  ");
    31         }
    32         // 执行game这个方法
    33         //game();
    34         System.out.println("\n请输入:");
    35         String input = sc.next();
    36         if(!(input.equals("y"))){//字符串要比较内容需要用equals
    37             System.out.println("not yes ");
    38         }else{
    39             System.out.println("yes");
    40         }
    41     }
    42 
    43     public static void game() {
    44         Scanner sc = new Scanner(System.in);
    45         System.out.println("******人机大战******");
    46         System.out.println("游戏开始……");
    47         int pokerNumber = 21;
    48         while (pokerNumber != 1) {
    49             System.out.print("人先选(1-4):");
    50             int people = sc.nextInt();
    51             pokerNumber -= people;
    52             System.out.println("人拿了:" + people + " 剩余:" + pokerNumber);
    53             int machine = 5 - people;
    54             pokerNumber -= machine;
    55             System.out.println("机器开始拿牌:" + machine + " 剩余:" + pokerNumber);
    56         }
    57         System.out.println("还剩1根,你输了!");
    58     }
    59 
    60 }

    好好理解游戏的算法

  • 相关阅读:
    O052、Create Volume 操作 (Part III)
    O051、Create Volume 操作 (Part II)
    O050、Create Volume 操作 (Part I)
    O049、准备 LVM Volume Provider
    O048、掌握 cinder-scheduler 调度逻辑
    O047、 Cinder 组件详解
    O046、掌握Cinder 的设计思想
    O045、理解 Cinder 架构
    O044、一张图秒懂 Nova 16种操作
    O043、计算节点宕机了怎么办
  • 原文地址:https://www.cnblogs.com/CocoonFan/p/2861713.html
Copyright © 2011-2022 走看看