Ever since you have a smartphone, always be concerned about the power of your phone. Your task is simple, use the program to print symbols to indicate the current phone's power.
Use 10 rows and 10 columns to represent the battery's power, while adding a border around the perimeter, and each row represents a 10% charge.
Assuming there is a 60% charge, the following is shown:
Run time limit: Unlimited
Memory Limit: Unlimited
Input: Multiple sets of test data, first behavior test Data Group N (n<10), followed by n rows, a number per line, indicating the power, this value may be 0,10,20, 30,40,50,60,70,80,90,100
Output: Each set of data outputs a battery charge, separated by 15 "=" For each set of data.
C
#include <iostream>#include <string>using namespace STD;voidDisplayintm) {cout<<"+----------+"<<endl;intn=Ten-m/Ten; for(intI=0; i<n;i++)cout<<"|----------|"<<endl; for(i=0; i<m/Ten; i++)cout<<"|++++++++++|"<<endl;cout<<"+----------+"<<endl;return;}intMain () {intNCin>>n;int*p=New int[n]; for(intI=0; i<n;i++)Cin>>p[i]; for(i=0; i<n-1; i++) {display (p[i]);cout<<"==============="<<endl; } Display (p[n-1]);Delete[]p;return 0; }
Java
ImportJava.util.Scanner; Public class Phonedian { Public void Show(intN) {System.out.println ("+----------+"); for(inti =0; I < (TenNTen); i++) System.out.println ("|----------|"); for(inti =0; I < n/Ten; i++) System.out.println ("|++++++++++|"); System.out.println ("+----------+"); } Public Static void Main(string[] args) {Phonedian PD =NewPhonedian (); Scanner s =NewScanner (system.in);intn = s.nextint ();int[] A =New int[n]; for(inti =0; I < n; i++) {Scanner SS =NewScanner (system.in); A[i] = Ss.nextint (); } for(inti =0; I < n-1; i++) {pd.show (a[i]); System.out.println ("==============="); } pd.show (A[n-1]); }}
Huawei Machine Test-Mobile battery