Huawei Machine Test-Mobile battery

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.