Huawei OJ training-simple bank numbering system, Huawei oj

Source: Internet
Author: User

Huawei OJ training-simple bank numbering system, Huawei oj

 

The topic of Level 5 is an intermediate question and an advanced question. The intermediate question is relatively simple and has been completed in half an hour. The questions are as follows:


Implement a simple bank Numbering System

 

Example of getting a get number: "get" or "get vip"

Call example: "call"

Example of deleting a delete number: "delete 5"

Example of getting the total number of queues by count: "count"

Example of the number N in the queue before countN: "countN"

Example of resetting a reset with a number: "reset"

Example of quit logout from the VPC: "quit"

 

Each line has only one input (for example, the C language can use the gets function to obtain the string of a line of input commands ).

1. If the input does not meet the requirements (for example, the command word is invalid or other errors are deemed to be input), an "error" must be output"

2. Use line breaks to separate each output (as shown in the following example)

 

 

 

Output:

 

1) Get the number. You can obtain common and vip numbers. If the initial status is "get", the normal number is obtained and the execution result is "1". If you enter "get vip" again, the VIP number is obtained, the execution result is "vip 2 ". If the number 2 at the end is deleted, "2" should be output when "get" is called again"

The VIP number has an absolute priority. The normal and vip numbers are numbered in a uniform manner. The number starts from 1. The maximum value is 100000.

 

2) call number. Obtain the number of the user to be processed. For example, if the current queuing number is 1 2 3 4 5 7, when "call" is entered, the result is "1". If 1 is the vip number, the result is "vip 1 ". if the call is performed six times in a row, the sixth execution result should be "error"

 

3) Delete the number. You can delete a number if you do not want it to be handled. Skip this number when you call the number. For example, if the current queuing number is 1 2 3 4 5, enter "delete 5", and the execution result is "5", if 5 is vip, "vip 5" is displayed ". Output "delete 5" again, and the execution result is "error"

 

4) obtain the total number of current queues. Obtains the number of current queues. For example, the current queuing number is 1 2 3 4 5 6 and the execution result is "6"

 

5) obtain the total number of queues before a certain number. For example, if the current queuing number is 1 2 3 4 5 7, enter "countN 7" and the execution result is "5"

 

6. Reset the number generator. For example, if "reset" is input, the VPC is reset to enter the initial state without output.

7. log out of the machine. For example, if you enter "quit", log out of the machine and no output is required.

 

 

Sample input:

Get
Get
Get
Get vip
Count
CountN 1
Call
Quit

Sample output:

1
2
3
Vip 4
4
1
Vip 4



My


Package breakthrough; import java. util. using list; import java. util. break; /*** implement a simple bank numbering system * @ author snail il **/public class Main {private static ticket list <String> queue = new ticket list <String> (); private static upload list <String> vipQueue = new upload list <String> (); private static int count = 0; private static int mulCall = 0; public static void main (String [] args) {created successfully = new Scann Er (System. in); String string = ""; boolean endFlag = false; while (! EndFlag) {string = signature. nextLine (); if (string. contains ("get") {get (string);} else if (string. contains ("call") {call ();} else if (string. contains ("delete") {delete (string);} else if (string. equals ("count") {count ();} else if (string. contains ("countN") {countN (string);} else if (string. equals ("reset") {reset ();} else if (string. equals ("quit") {endFlag = true;} else {System. out. println ("error") ;}} failed. Close ();}/** get the number. You can obtain common and vip numbers. * If the initial status is "get", the normal number is obtained. The execution result is "1". * If you enter "get vip" again, the VIP number is obtained, the execution result is "vip 2 ". * If the number 2 at the end is deleted, "2" * "VIP number has an absolute priority when" get "is called again. The normal and vip numbers are numbered in a uniform manner. * The number starts from 1. The maximum value is 100000. */public static void get (String string) {count ++; mulCall = 0; if (string. equals ("get") {queue. add (String. valueOf (count); System. out. println (count);} else if (string. equals ("get vip") {vipQueue. add ("vip" + count); System. out. println ("vip" + count);} else {System. out. println ("error") ;}}/** call number. Obtain the number of the user to be processed. * For example, if the current queuing number is 1 2 3 4 5 7, * When "call" is entered, the execution result is "1". * If 1 is the vip number, it is "vip 1 ". * if the call is performed six times in a row, the sixth execution result should be "error" */public static void call () {if (! Queue. isEmpty () |! VipQueue. isEmpty () {mulCall ++; if (mulCall = 6) {System. out. println ("error");} else {if (! VipQueue. isEmpty () {System. out. println (vipQueue. remove (0);} else {System. out. println (queue. remove (0) ;}} else {System. out. println ("error") ;}}/** Delete the number. * You can delete a number if you do not want it to be handled. If you call a number, the number is skipped. * For example, if the current queuing number is 1 2 3 4 5, enter "delete 5", and the execution result is "5", * If 5 is vip, "vip 5" is displayed ". Output "delete 5" again, and the execution result is "error" */public static void delete (String string) {String [] string2 = string. split (""); if (string2.length! = 2 |! String2 [1]. matches ("\ d") {System. out. println ("error"); return;} else {for (int I = 0; I <vipQueue. size (); I ++) {if (vipQueue. get (I ). contains (string2 [1]) {System. out. println (vipQueue. remove (I); return ;}}for (int I = 0; I <queue. size (); I ++) {if (queue. get (I ). contains (string2 [1]) {System. out. println (queue. remove (I); return ;}} System. out. println ("error"); return ;}} public static void count () {System. Out. println (queue. size () + vipQueue. size (); return;} public static void countN (String string) {String [] string2 = string. split (""); if (string2.length! = 2 |! String2 [1]. matches ("\ d") {System. out. println ("error"); return;} else {int vipLength = vipQueue. size (); for (int I = 0; I <vipLength; I ++) {if (vipQueue. get (I ). contains (string2 [1]) {System. out. println (I); return ;}} int length = queue. size (); for (int I = 0; I <length; I ++) {if (queue. get (I ). equals (string2 [1]) {// System. out. println ("vipLength" + vipLength + ", I" + I); System. out. println (I + vipLength); return;} System. out. println ("error"); return ;}} public static void reset () {queue. clear (); vipQueue. clear (); count = 0; mulCall = 0 ;}}




How can the numbering system in the bank be implemented, including connection methods with the ledscreen, as detailed as possible,

Do you want to do it yourself? Or do you want to know? The host is usually a computer, a touch screen, and a software. The counter host is generally made of a single-chip microcomputer, and the window display is generally made of a single-chip microcomputer, the host computer software and multiple Windows form a 485 master-slave communication network. The host regularly queries the host machine. The host uploads the case information to the host machine and then plays the response sound, at the same time, the information to be displayed is transmitted to the corresponding window display.
 
I want to create a single-chip-based queuing system, which uses the wireless transmission chip A7105. I don't know where to start.

If it is similar to a bank's numbering system, it is in the form of a host + multiple terminals.
The host and terminal structures are similar, both in the form of single-chip microcomputer + A7105, and LCD display can be added.
Click the host button to generate a number and send messages to each terminal.
Click the terminal to report the number .. That's it.
 

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.