Mispelling4

Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2592    Accepted Submission(s): 1731

Problem Description

Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string.

Input

The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing M, a space, and a single word made up of uppercase letters only. M will be less than or equal to the length of the word. The length of the word is guaranteed to be less than or equal to 80.

Output

For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the misspelled word. The misspelled word is the input word with the indicated character deleted.

Sample Input

4

4 MISSPELL

1 PROGRAMMING

7 CONTEST

3 BALLOON

Sample Output

1 MISPELL

2 ROGRAMMING

3 CONTES

4 BALOON

利用erase函数。由于remove()函数不是成员,因此不能调整链表的长度。remove()函数并不是真正的删除,要想真正删除元素则可以使用erase()或者resize()函数

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int t,b=;
cin>>t;
while(t--)
{
++b;
int d;
string a;
cin>>d>>a;
string::iterator it=a.begin();
a.erase(it+d-); //里面的是迭代器。
printf("%d ",b);
cout<<a<<endl;
}
return ;
}

(erase) Mispelling4 hdu1984的更多相关文章

  1. c++ 列表删除元素(erase)

    #include <list> #include <iostream> #include <iterator> using namespace std; int m ...

  2. Linux学习笔记(11)软件包管理

    Linux中的软件包分为源码包(脚本安装包)及二进制包(RPM包.系统默认包).其中源码包的优点是: 1)源码包是开源的,如果有足够的能力,可以修改源代码: 2)可自由选择所需的功能: 3)源码包需编 ...

  3. c++字符串详解(转)

    之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至是 ...

  4. (C++)String的用法

    (转自http://www.cnblogs.com/yxnchinahlj/archive/2011/02/12/1952550.html) 之所以抛弃char*的字符串而选用C++标准程序库中的st ...

  5. Linux 基础(3)

    Linux 基础(三) rpm与yum学习 本篇分享一下自己学习rpm和yum过程中的一些心得,自己在使用yum过程中由于自己的虚拟机网络的问题在学习这一块品尝到不少苦头,还望学习这块的盆友先检查一下 ...

  6. linux操作系统基础篇(五)

    Linux网络以及rpm安装yum源的配置 1.Linux网络 1. 使用ifconfig命令来维护网络1) fconfig命令的功能:显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址.2) ...

  7. linux学习笔记整理(七)

    第八章 Centos7软件包的管理与安装本节所讲内容:8.1 使用rpm命令-安装-查看-卸载-rpm软件包8.2 yum管理软件包8.3 实战tar源码包管理-srpm源码包安装方法 8.1 软件包 ...

  8. C++ string(转)

    C++中string是标准库中一种容器,相当于保存元素类型为char的vector容器(自己理解),这个类提供了相当丰富的函数来完成对字符串操作,以及与C风格字符串之间转换,下面是对string一些总 ...

  9. NAND flash学习所获----(Zac)

    Nand Falsh外围电路:peripheral circuit 1.Nand flash里至少有2个state Machine(controller),即2个主控. 一个主控:负责处理前端事情. ...

随机推荐

  1. 11.18 Daily Scrum

    这两天开发人员陆续提交了自己开发的部分. 目前所有开发任务都已经完成,剩下的只是测试和整合,做最后的冲刺. 明天的任务: 李承晗:测试与整合

  2. 软件工程(GZSD2015) 第三次作业提交进度

    第三次作业题目请查看这里:软件工程(GZSD2015)第三次作业 开始进入第三次作业提交进度记录中,童鞋们,虚位以待哈... 2015年4月19号 徐镇.尚清丽,C语言 2015年4月21号 毛涛.徐 ...

  3. 基于Windows Subsystem for Linux (WSL) 【Ubuntu】在WIN10 Home Edition安装Docker

    root@Andy-PC:~# uname -a Linux Andy-PC --Microsoft #-Microsoft Fri Apr :: PST x86_64 x86_64 x86_64 G ...

  4. Exception while invoking TaskListener: Exception while invoking TaskListener: null

    https://community.alfresco.com/thread/225041-exception-while-invoking-tasklistener-null Ok, so the p ...

  5. docker发现端口是tcp6的 导致无法访问前端

    最近偶尔发现一个比较奇怪的现象,netstat 查看监听的服务端口时,却只显示了 tcp6 的监控, 但是服务明明是可以通过 tcp4 的 ipv4 地址访问的,那为什么没有显示 tcp4 的监听呢? ...

  6. 转帖 云和恩墨 http://www.eygle.com/archives/2015/06/sql_version_count.html

    SQL多版本控制 - _CURSOR_OBSOLETE_THRESHOLD   作者:eygle |English [转载时请标明出处和作者信息]|[恩墨学院 OCM培训传DBA成功之道]链接:htt ...

  7. 前端存储loaclForage

    以前使用本地存储,首先会想到localstorage或者session storage,将要存储的数据转化成字符串后进行setItem操作,但是使用local storage 有几个问题: 1.它是同 ...

  8. python中Switch/Case实现

    学习Python过程中,发现没有switch-case,过去写C习惯用Switch/Case语句,官方文档说通过if-elif实现.所以不妨自己来实现Switch/Case功能. 方法一 通过字典实现 ...

  9. js screen

    windows.screen對象包含包含對象屏幕的信息: screen.availheight;屏幕高度 screen.availwidth;屏幕寬度

  10. python之工作举例:通过复制NC文件来造数据

    # 通过对NC文件复制来造数据 import os, shutil # 遍历的根目录 root_dir = "D:\\test_data\\DISASTER\\" # 获取NC文件 ...