zoukankan      html  css  js  c++  java
  • 47 读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。

    题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。 

     1    public class _047ReadNumberPrintStar {
     2 
     3     public static void main(String[] args) {
     4         readNumberPrintStar();
     5     }
     6 
     7     private static void readNumberPrintStar() {
     8         Scanner s = new Scanner(System.in);
     9         int n = 1, num;
    10         while (n <= 7) {
    11             do {
    12                 System.out.println("请输入一个1--50之间的整数:");
    13                 num = s.nextInt();
    14             } while (num < 1 || num > 50);
    15             for (int i = 1; i <= num; i++) {
    16                 System.out.print("*");
    17             }
    18             System.out.println();
    19             n++;
    20         }
    21     }
    22 }
  • 相关阅读:
    [六省联考2017]相逢是问候
    [CQOI2017]老C的键盘
    [CQOI2017]老C的任务
    [CQOI2017]小Q的棋盘
    <sdoi2017>树点涂色
    三分法
    最长回文子串
    hdu3261
    spoj694
    poj1743
  • 原文地址:https://www.cnblogs.com/liuyangfirst/p/6544553.html
Copyright © 2011-2022 走看看