SDNU 1210.通话记录

Total Submission(s): 204    Accepted Submission(s): 74

Description

使用3个队列,分别保留手机上最近10个,(0)未接来电、(1)已接来电、(2)已拨电话。

Input

全部通话记录,每行一条记录。

每条记录包含两个数字,第一个数代表记录类型,第二个数代表手机号码。

Output

分3列输出未接来电、已接来电、已拨电话。

列之间用空格分割,后接电话在最先输出,不足10条用0占位。

Sample Input

2	18270477699
1	10149800116
0	19906559817
1	16209018105
1	16804212234
2	19289130583
1	17982711123
0	10897630486
1	11860787674
0	15192777554

Sample Output

15192777554 11860787674 19289130583
10897630486 17982711123 18270477699
19906559817 16804212234 0
0 16209018105 0
0 10149800116 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

int main()
{
    string miao, record;
    stack<string>a, b, c;
    for(int i = 0; i<10; i++)
    {
        a.push("0");
        b.push("0");
        c.push("0");
    }
    while(cin >> miao >> record)
    {
        if(miao == "0")a.push(record);
        else if(miao == "1")b.push(record);
        else if(miao == "2")c.push(record);
    }
    for(int i = 0; i<10; i++)
    {
        cout << a.top() <<' '<< b.top() << ' '<<c.top()<<endl;
        a.pop();
        b.pop();
        c.pop();
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/RootVount/p/10383007.html
今日推荐