package com.homework;
import java.util.*;
/*
* 算心中的图形程序
*/
public class H1 {
public static void main(String[] args) {
//in用于输入时
Scanner in = new Scanner(System.in);
int loop = 1;
//定义一个存放图像的数组
String[] picture = new String[10];
picture[0] = "!";
picture[1] = "@";
picture[2] = "#";
picture[3] = "^";
picture[4] = "%";
picture[5] = "(";
picture[6] = ")";
picture[7] = ">";
picture[8] = "<";
picture[9] = "*";
while(loop==1){
//定义随机数
Random rand = new Random();
int k = rand.nextInt(10);
//用for循环显示图形
for(int i=1;i<=100;i++){
int a = rand.nextInt(10);
if(i%9==0)
a=k;
System.out.print(i+" "+picture[a]+" ");
if(i%10==0){
System.out.println();
}
}
//提示语句
System.out.println("请输入神7,将显示你心中的图像:");
int n = in.nextInt();
if(n==7)
System.out.println(picture[k]);
else
System.out.println("你输入的数字不是7,请输入7!!");
System.out.println("重新测试输入1,退出输入2");
loop = in.nextInt();
}
}
}
算命程序
最新推荐文章于 2024-06-24 10:17:56 发布