算命程序

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/csdt_csdt/article/details/12831501
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();
		}
	 }
}

展开阅读全文

没有更多推荐了,返回首页