1232: 手機剩餘電量
時間限制: 1 Sec 內存限制: 128 MBjava
題目描述測試
讓咱們來輸出手機電池的剩餘電量。
例如:剩餘電量n=8
圖案爲:blog
輸入內存
輸入包含多組測試實例,每一個實例爲一個正整數n,以n等於-1結束。n<=100class
輸出import
對於每組實例,輸出手機剩餘電量。im
樣例輸入next
11
66
-1
static
樣例輸出di
*----------*
| |
| |
| |
| |
| |
| |
| |
| |
| !|
|!!!!!!!!!!|
*----------*
*----------*
| |
| |
| |
| !!!!!!|
|!!!!!!!!!!|
|!!!!!!!!!!|
|!!!!!!!!!!|
|!!!!!!!!!!|
|!!!!!!!!!!|
|!!!!!!!!!!|
*----------*
---------------------
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int[100]; int t = 0; for (int i = 0; i < a.length; i++) { t++; a[i] = sc.nextInt(); if(a[i]==-1) { t--; break; } } for (int i = 0; i < a.length; i++) { if(t>0) { System.out.println("*----------*"); if(a[i]>100) { a[i] = 100; } int temp = 100-a[i]; int p = 0; while(temp>=10) { System.out.println("| |"); p++; temp -= 10; } System.out.print("|"); for (int j = 0; j < temp; j++) { System.out.print(" "); } for (int j = 0; j < 10-temp; j++) { System.out.print("!"); } System.out.println("|"); while(p<9) { System.out.println("|!!!!!!!!!!|"); p++; } System.out.println("*----------*"); t--; }else { break; } } } } /************************************************************** Problem: 1232 User: 20161514325 Language: Java Result: 正確 Time:245 ms Memory:13852 kb ****************************************************************/