Introduction to the Garlic Course competition--Recent call logs (STL queue) process

Source: Internet
Author: User

Garlic June a few days ago the most beloved wheat mobile phone broke, the new phone and a few days to arrive, so the garlic June will not be used for a long time to cherish the Connaught Chicken Duck non-smart phone. The phone has a very small storage space, so that missed calls, incoming calls, and dialed calls can only hold the last 10 records separately.

Garlic bought the phone after the missed calls, received calls and dialed phone records are all given. Wit's garlic can guess that this cell phone uses the loop queue to achieve the function of the recent record, but it does not write code (no hand how to write π_π), so it came to the algorithm in the course of you. Can you help it?

Input format:

Each record contains two digits, the first number represents the record type, and the second number represents the mobile number.

0 of these represent missed calls, 1 for incoming calls and 2 for calls.

Output format:

3 columns output missed calls, received calls, dialed calls.

Columns separated by a space, followed by the phone in the first output, less than 10 with 0 placeholder. If you do not understand the reference sample output ha.

Sample input
218270477699110149800116019906559817116209018105116804212234219289130583117982711123010897630486111860787674015192777554
Sample output
15192777554 11860787674 1928913058310897630486 17982711123 1827047769919906559817 16804212234 00 16209018105 00 10149800116 00 0 00 0 00 0 00 0 00 0 0
1#include <iostream>2#include <cstdio>3#include <queue>4 using namespacestd;5 Const intLEN =Ten;6 //Custom Loop queue classes to save the list of calls that are required by the topic7 //An example of calling definitions in a program is as follows:8 //circular_queue Q;9 //if you want to define an array, such as this one, you need to define an array of circular queues with a length of 3, then refer to the following definitions:Ten //Circular_queue q[3]; One classCircular_queue { A  Public: -     //custom classes are used in STL deque, which is the double-ended queue -     //The double-ended queue, as the name implies, can be inserted or deleted from the head or tail of the queue thedeque<string>Q; -     //constructor to empty the queue -     //The constructor automatically calls when declaring a class variable - Circular_queue () { + q.clear (); -     } +     //inserts an element at the end of the queue, and ejects the first element of the team if the length exceeds the limit (len=10) A     //examples of calling methods are: at     //q.add ("Hello World"); -     voidAddstringstr) { -         //inserting elements at the end of a team - q.push_back (str); -         //determine if the queue length exceeds the limit -         if(Q.size () >LEN) { in             //if the length exceeds the limit, the first element of the team pops up - Q.pop_front (); to         } +     } -     //returns the value of the tail element if the queue is empty and returns a string of "0" as requested by the Polygon . the     stringGet_tail () { *         //determine if the queue is empty $         if(Q.size () >0) {Panax Notoginseng             //Back to the end of the team element -             returnQ.back (); the}Else { +             //returns a default string of "0" A             return "0"; the         } +     } -     //eject the tail element if the queue is empty and does not operate $     voidPop_tail () { $         //determine if the queue is empty -         if(Q.size () >0) { -             //Popup Tail Element the Q.pop_back (); -         }Wuyi     } the }; - intMain () { Wu     int_type; -     stringstr; AboutCircular_queue q[3]; $     //read the end of the file, one integer and one string per line -      while(Cin >> _type >>str) { -         //This implements the insert operation of the loop queue.  -         //the range of _type is 0,1,2, which corresponds exactly to the three subscripts of the Q array A         //insert element to invoke the loop queue's Add (str) method +         //For example, for loop queue Q, the code for inserting elements is q.add (str); the         //Smart You, just write the answer in the next line. -  $ Q[_type].add (str); the     } the      for(inti =0; I <Ten; ++i) { the         //The Get_tail () method to invoke the loop queue by outputting the tail element of the three loop queue the         //For example, for the loop queue Q, the code to get the value of the tail element is Q.get_tail (); -  incout << q[0]. Get_tail () <<" "<< q[1].get_tail () <<" "<< q[2].get_tail () <<Endl; the  the         //Next, delete the tail elements of the three loop queues separately About         //for circular queue Q, the code for removing the tail element of the loop queue is Q.pop_tail (); the          theq[0].pop_tail (); theq[1].pop_tail (); +q[2].pop_tail (); -     } the     return 0;Bayi}

Introduction to the Garlic Course competition--Recent call logs (STL queue) process

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.