java里的符号错误
import java.util.Scanner;import java.util.Random;
public class gm
{
public static void main(String[] args)
{
Scanner w = new Scanner(System.in);
Random random = new Random();
System.out.println("给你在一到一百内猜一个数字");
int r = random.nextInt(100)+1;
int a = 0;
System.out.println("请输入猜测数字");
while(true);
{
int a1 = w.nextInt();
if(r > a1)
{
System.out.println("偏小了");
}
else if(r < a1)
{
System.out.println("偏小了");
}
else
{
System.out.println("正确");
break;
}
}
}
}
一直对我的{}符号有意见老是报错 你后面多了个分号
while(true) import java.util.Scanner;
import java.util.Random;
public class gm
{
public static void main(String[] args)
{
Scanner w = new Scanner(System.in);
Random random = new Random();
System.out.println("给你在一到一百内猜一个数字");
int r = random.nextInt(100)+1;
int a = 0;
System.out.println(r);
System.out.println("请输入猜测数字");
while(true)
{
int a1 = w.nextInt();
if(r > a1)
{
System.out.println("偏小了");
}
else if(r < a1)
{
System.out.println("偏大了");
}
else
{
System.out.println("正确");
break;
}
}
}
}
页:
[1]