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 ...
随机推荐
- hasLayout与Block formatting contexts的学习(上)
hasLayout与Block formatting contexts的学习 @(css BFC)[IE hasLayout|妙瞳] hasLayout是什么? haslayout 是Windows ...
- 关于Extjs使用window.opener报错
项目中使用window.opener 刷新父窗口表格,父窗口表格IE8报错, window.opener.Ext.getCmp('SalesCompanyGridPanel').getStore(). ...
- C# Generic(转载)
型(generic)是C#语言2.0和通用语言运行时(CLR)的一个新特性.泛型为.NET框架引入了类型参数(type parameters)的概念.类型参数使得设计类和方法时,不必确定一个或多个具体 ...
- 【html】【16】高级篇--毛玻璃效果[模糊]
参考: http://www.zhangxinxu.com/wordpress/2013/11/%E5%B0%8Ftip-%E4%BD%BF%E7%94%A8css%E5%B0%86%E5%9B%BE ...
- Golang中解析json,构造json
json解析是如今(网络)应用程序开发中最不可或缺的一环了.许多语言需要库支持才可以解析.构造json,但Golang凭借着原生库就可以很好地做到这一点. json的基本表现形式有两个:struct与 ...
- Lisp与JAVA的酷毙结合——abcl
最近看了一本叫做<黑客与画家>的书,其中对于Lisp语言大加褒奖.自己试着用了一下,虽然确实有反人类之嫌,但是确实是一门不错的语言,New Architect杂志上有一篇介绍ITA软件公司 ...
- JavaScript基础-对象<1>
1.JavaScript内部对象属性和方法 (1)内置String对象 String 对象是JavaScript的核心对象之一. 创建一个sting对象: var a="this defin ...
- 禁用Linux bash rm --force
防止无意的Linux bash rm --force 二.禁用rm -rf 因为rm -rf 删除文件的时候,经常会不小心将系统文件或者多个有用的目录删除掉.有两种方法:1,每次删除都用-i(inte ...
- Eclipse启动报错Java was started but returned exit code=13
启动Eclipse的时候报错Java was started but returned exit code=13,这个错误的原因是由于eclipse版本与jdk版本不符导致的,可能你的eclipse是 ...
- debian 学习记录-2 -账户 -关机
linux考虑系统安全设定了root账号和user账号 权限较低的user账号下,连关机命令都执行不了…… 用户切换... 用户切换1 命令su(在user账号下,即可开启root账号模式) 用户切换 ...