保手感啊。不过好简单的样子..
- import java.util.*;
- public class test13{
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- System.out.println("请输入7个数:");
- int[] a = new int[7];
- int i = 0;
- while (i < 7)
- {
- a[i] = sc.nextInt();
- if (a[i] > 50 || a[i] < 1)
- System.out.println("请输入1-50的数");
- else i++;
- }
- for(int j = 0; j < 7; j++)
- {
- System.out.print("\n" + a[j] + "个*:");
- for(int k = 0; k < a[j]; k++)
- System.out.print("*");
- }
- sc.close();
- }
- }
复制代码 |