本帖最后由 新生张洋 于 2018-10-9 12:23 编辑
public class jiujiu {
public static void main(String[] args) {
for (int i = 1; i <=9; i++) {
for (int j = 1; j <=i; j++) {
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}
}
}
这是我开始学的觉得一个很装X的程序,后来又学了几个感觉太丢脸了。
public class DemoOne {
public static void main(String[] args) {
//获取电脑的随机值
Random random = new Random();
Scanner scanner = new Scanner(System.in);
while (true) {
int computer = random.nextInt(3);
System.out.println(computer);
System.out.println("请输入您猜测的数据(0是石头,1是剪刀,2是布):请输入0,1,2");
int me = scanner.nextInt();
if (me == 0) {//石头
if (computer == 0) {
System.out.println("平局!");
} else if (computer == 1) {
System.out.println("玩家胜!");
} else if (computer == 2) {
System.out.println("电脑胜!");
break;
}
} else if (me == 1) { //剪刀
if (computer == 0) {
System.out.println("电脑胜!");
} else if (computer == 1) {
System.out.println("平局!");
} else if (computer == 2) {
System.out.println("玩家胜!");
break;
}
} else if (me == 2) {//布
if (computer == 0) {
System.out.println("玩家胜!");
break;
} else if (computer == 1) {
System.out.println("电脑胜!");
} else if (computer == 2) {
System.out.println("平局!");
}
} else {
System.out.println("数据有问题;");
}
}
}
这个是我学的后面的。差距有点大
|
|