• 水NOJ Duplicate Removal


    Duplicate Removal

    时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
    总提交 : 247            测试通过 : 146 

    题目描述

    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>
    #include<stdlib.h>
    #include<stdio.h>
    #include<string>
    using namespace std;
    const int N=26;
    int a[N];
    int main()
    {
        int n;
        while(scanf("%d",&n),n)
        {
            int a[26];
            for(int i=0;i<n;i++)
            {
                scanf("%d",&a[i]);
            }
            printf("%d",a[0]);
            for(int i=1;i<n;i++)
            {
               if(a[i]!=a[i-1])
               {
                   printf(" %d",a[i]);
               }
            }
            cout<<" $"<<endl;
        }
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    学习笔记——SQL SERVER2014内存数据库
    学习笔记——WCF
    线程
    文件内容操作类-RandomAccessFile
    文件操作类-file-创建文件夹
    同步方法解决同步问题
    同步代码块
    停止线程
    使用泛型来优化坐标类
    数据操作流-DataOutputStream
  • 原文地址:https://www.cnblogs.com/Tobyuyu/p/4965688.html
Copyright © 2020-2023  润新知