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) 我遵循了有关创建画布的教程,但是它不起作用,也没有在其上绘制矩形。是否有必要在<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) 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程序.
它如下:
将布尔变量"first"设置为true.
已成功读取另一个值
到目前为止我有这个:
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)