小编use*_*786的帖子

Nim游戏 - 指定获胜者

import java.util.Scanner;
/**
 *@author Andy 
 *@verison 21.11.2012
 */
public class NimGame
{
public static void main (String[] args)
{
    System.out.println ("**********      Hello Welcome to the game Nim           *********");
    System.out.println ("               The game is relatively simple....        ");
    System.out.println ("               This is a game for two players.          "); 
    System.out.println ("            There is a heap containing 10 to 20 stones.");
    System.out.println ("           Players take turns to remove 1-4 stones     "); 
    System.out.println ("           The player who removes the last stone wins. ");
    System.out.println ("******************************************************************"); …
Run Code Online (Sandbox Code Playgroud)

java

5
推荐指数
1
解决办法
2739
查看次数

画布不显示

我遵循了有关创建画布的教程,但是它不起作用,也没有在其上绘制矩形。是否有必要在<head>. 任何帮助,将不胜感激!

这是一个带有我的代码的JSFiddle

<!DOCTYPE html>
<html>
    <head>
        <title>Simple animations in HTML5</title>
    </head>
<body>
<h2> Optical Illusion </h2>
<video id="illusion" width="640" height="480" controls>
    <source src="Illusion_movie.ogg">
</video>

<div id="buttonbar">
     <button onclick="changeSize()">Big/Small</button>
</div>

<p>
Watch the animation for 1 minute, staring at the centre of the image. Then look at something else near you.
For a few seconds everything will appear to distort.
Source: <a href="http://en.wikipedia.org/wiki/File:Illusion_movie.ogg">Wikipedia:Illusion     movie</a>
</p>

<script>
    var myVideo=document.getElementById("illusion");
    var littleSize = false;
    function changeSize()
    {
        myVideo.width …
Run Code Online (Sandbox Code Playgroud)

javascript canvas

5
推荐指数
1
解决办法
1万
查看次数

如果陈述不等于

import java.util.Scanner;
public class RockPaperScissors
 {
public static void main (String[] args)
{
    Scanner scan = new Scanner (System.in);
    System.out.println("Player 1: Choose rock, paper or scissors: ");
    String Player1 = scan.next().toLowerCase();
    System.out.println("Player 2: Choose rock, paper or scissors: ");
    String Player2 = scan.next().toLowerCase();
    System.out.println ("Player 1 chose " + Player1);
    System.out.println ("Player 2 chose " + Player2);

    if (Player1.!equals("rock" + "paper" + "scissors")
    {
        System.out.println ("Please insert either Rock Paper or Scissors!);
    }
    if (Player1.equals(Player2))
    {
        System.out.println ("Its a tie!"); …
Run Code Online (Sandbox Code Playgroud)

java if-statement

3
推荐指数
1
解决办法
4万
查看次数

找到一组输入的最小值

我已经获得伪代码转换为Java程序.

它如下:

  • 将布尔变量"first"设置为true.

  • 已成功读取另一个值

    • 如果第一个是真的
      • 将最小值设置为刚刚读取的值
      • 首先设置为false
    • 否则,如果该值小于最小值
      • 将最小值设置为值
    • 打印最小值

到目前为止我有这个:

import java.util.Scanner;
public class InputLoop
{
    public static void main(String[] args)
    {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter an integer");

    boolean first = true;
    int min = 0;
    int val = 0;

    while (scan.hasNextInt())
    {
        val = scan.nextInt();
        System.out.println("Enter an integer");
        if (first == true) 
        {
            min = val;
            first = false;
        } 

        else if (val < min) 
        {
            System.out.println("Enter an integer");
            min = val;

        }

        while (!scan.hasNextInt())
        { …
Run Code Online (Sandbox Code Playgroud)

java loops

1
推荐指数
1
解决办法
1762
查看次数

标签 统计

java ×3

canvas ×1

if-statement ×1

javascript ×1

loops ×1