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;
}
1089-Duplicate Removal的更多相关文章
- 【Leetcode_easy】1089. Duplicate Zeros
problem 1089. Duplicate Zeros 题意: solution: 其中关于虚拟新数组的下标的计算还是有点迷糊... class Solution { public: void d ...
- POJ 3916:Duplicate Removal 将相近的重复元素删除
Duplicate Removal Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1745 Accepted: 1213 ...
- [LeetCode]1089. Duplicate Zeros
Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remainin ...
- 【leetcode】1089. Duplicate Zeros
题目如下: Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the re ...
- LeetCode 1089. 复写零(Duplicate Zeros) 72
1089. 复写零 1089. Duplicate Zeros 题目描述 给你一个长度固定的整数数组 arr,请你将该数组中出现的每个零都复写一遍,并将其余的元素向右平移. 注意:请不要在超过该数组长 ...
- 【LEETCODE】49、数组分类,简单级别,题目:566,1089
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...
- JavaScript性能优化
如今主流浏览器都在比拼JavaScript引擎的执行速度,但最终都会达到一个理论极限,即无限接近编译后程序执行速度. 这种情况下决定程序速度的另一个重要因素就是代码本身. 在这里我们会分门别类的介绍J ...
- MySQL Information Functions
Table 12.18 Information Functions Name Description BENCHMARK() Repeatedly execute an expression CHAR ...
- AIX 第4章 指令记录
root@db:/#lsdev -Cc disk --查看磁盘设备信息 -C customized -c class hdisk0 Available 00-08-00 SAS Dis ...
- Java 8 Stream API Example Tutorial
Stream API Overview Before we look into Java 8 Stream API Examples, let’s see why it was required. S ...
随机推荐
- oracle交集,并集,差集
引自:http://www.2cto.com/database/201308/238777.html [sql] create table test1 ( name ), NN ) ); insert ...
- HTML5规范的本地存储
在HTML5 中定义了两种本地存储的,Web Storage 和本地数据库 SQL Database . 用来检查判断浏览器是否支持 Web Storage if(window.localStorag ...
- arclist底层模板字段,可以调用的字段列表
arclist底层模板字段,可以调用的字段列表 用DedeCMS做站,arclist是用得最多的标签,因为他是调用文章的基本标签,功能也非常强大,他的底层字段比较多,我们平时使用还没有用到一半,但 ...
- C#基础总复习02
继续更新第二篇: 1:一元运算符:++ -- ++:不管是前加加还是后加加,变量的值最终都会自身加一. 前加加和后加加的区别体现在参与运算的时候,如果是后加加,则首先拿原值参与运算, 运算完成后再自身 ...
- Python 问题集
1.问题:打开Python的IDLE(集成开发环境/Integrated DeveLopment Environment) 然后在Python的shell中做如下动作时: >>>py ...
- 使用Class.getResource和ClassLoader.getResource方法获取文件路径
自从转投Java阵营后,一直发下Java程序的路径读取异常麻烦,因此查阅了比较多的版本内容,整合了一份自己的学习笔记.主要使用Class及通过ClassLoader来动态获取文件路径. 查阅链接如下: ...
- VS2005调试时无法找到调试信息解决方法
调试C++程序的时候出现,无法找到.exe的调试信息,或者调试信息不匹配.未使用调试信息生成二进制文件.解决方法:打开菜单项目->项目属性页: 1.选择配置属性->链接器->调试-& ...
- mysql---字符集详解
常用的字符集包括ASCII ,GB2312 , GBK , UTF-8 ,Unicode 首先要知道 ASCII编码: 用一个字节来标识0-9的数字.大小写字母.及一些标点和不可见字符.1个字节8位, ...
- 一套帮助你理解C语言的测试题(转)
前言 原文链接:http://www.nowamagic.net/librarys/veda/detail/775 内容 在这个网站(http://stevenkobes.com/ctest.html ...
- htmlt中的块状元素与内联元素
块元素(block element) address - 地址 blockquote - 块引用 center - 举中对齐块 dir - 目录列表 div - 常用块级容易,也是CSS layout ...