zoukankan      html  css  js  c++  java
  • 1089-Duplicate Removal

    描述

    The company Al's Chocolate Mangos has a web site where visitors can guess how many chocolate covered mangos are in a virtual jar. Visitors type in a guess between 1 and 99 and then click on a "Submit" button. Unfortunately, the response time from the server is often long, and visitors get impatient and click "Submit" several times in a row. This generates many duplicate requests. Your task is to write a program to assist the staff at ACM in filtering out these duplicate requests.

    输入

    The input consists of a series of lines, one for each web session. The first integer on a line is N, 0 < N ≤ 25, which is the number of guesses on this line. These guesses are all between 1 and 99, inclusive. The value N = 0 indicates the end of all the input.

    输出

    For each input data set, output a single line with the guesses in the original order, but with consecutive duplicates removed. Conclude each output line with the dollar sign character '$'. Note that there is a single space between the last integer and the dollar sign.

    样例输入

    5 1 22 22 22 3

    4 98 76 20 76

    6 19 19 35 86 86 86

    1 7

    0

    样例输出

    1 22 3 $

    98 76 20 76 $

    19 35 86 $

    7 $

    #include<iostream>
    using namespace std;
    int main()
    {
        int n,x;
        while(cin>>n&&n)
        {
            int temp=-1;
            while(n--)
            {
                cin>>x;
                if(x!=temp) 
                {
                    cout<<x<<" ";
                    temp=x;
                }
            }
            cout<<"$"<<endl;
        }
        return 0;
    } 
    

      

  • 相关阅读:
    洛谷 1341 无序字母对
    POJ 2774 后缀数组 || 二分+哈希
    HDU 1251 统计难题
    【解题报告】AtCoder ABC115 (附英文题目)
    【模板】后缀数组
    洛谷 3567/BZOJ 3524 Couriers
    Beta 冲刺 (1/7)
    团队项目评测
    beta冲刺前准备
    Alpha冲刺——事后诸葛亮
  • 原文地址:https://www.cnblogs.com/Rosanna/p/3436868.html
Copyright © 2011-2022 走看看