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 ...
随机推荐
- npm更换淘宝镜像
镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 1.通过config命令 npm config set registry https://regist ...
- select2的基本用法
公司有个项目需要用到类似百度搜索功能的下拉框,自然想到使用select2. 先看下select2的效果图,如下: 下来简单介绍下这个控件的基本用法,主要简单介绍下远程加载数据: 1.首先引入需要的文件 ...
- viewpager双层嵌套,子viewpager无限循环无法手动滑动
项目中首页是用viewpager+fragment集成的,第一个fragment有广告轮播图使用viewpager实现的,开始就遇到是广告图无法手动滑动,事件被外层的viewpager拦截响应切换到下 ...
- 【转】prototype扩展的JavaScript常用函数库
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...
- c#局域网文件搬移
/// kongxiang--2013.7.23 /// using System;using System.Collections.Generic;using System.Linq;using S ...
- SQL Server高级内容之表表达式和复习
1. 表表达式 (1) 将表作为一个源或将查询的一个结果集作为一个源,对源做处理,然后得到一个新的数据源,对其进行查询. (2)表表达式放在from子句中 (3)派生表,将表的查询得到的结果集作为一 ...
- JavaScript高级程序设计(三):基本概念:数据类型
特别注意:ECMAScript是区分大小写的. 一.变量 1.ECMAScript的变量是松散型的.所谓松散型就是可以用来保存任何类型的数据.即每个变量仅仅是一个用于保存值的占位符而已.定义变量时要使 ...
- (三)JAVA使用POI操作excel
1,单元格对齐方式 Demo8.java package com.wishwzp.poi; import java.io.FileOutputStream; import java.util.Date ...
- iOS scrollView/tableView滚动到底部
//项目要求tableView滚动到底部就自动加载下一页,UITableView继承自UIScrollView 所以可以在//scrollViewDidEndDecelerating这个方法中进行判断 ...
- C++中各种<string,T>关联方式的速度对比
把<string,T>(T为任意类型)关联起来,是很常见的需求.如笔者最近要做一个贝叶斯算法的垃圾邮件过滤器,就需要把每个单词与频率对应起来,做成一个表.而当单词很多时,对于每个单词做一遍 ...