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. Substrings Sort

    You are given nn strings. Each string consists of lowercase English letters. Rearrange (reorder) the ...

  2. 撰写POPUSH需求文档

    不当家不知柴米贵,撰写了正规的软件需求文档才知道软件工程的复杂性 感谢@洪宇@王需@江林楠下午的加班加点,五个人正闷在406B奋斗中,加油!

  3. 分布式版本控制系统Git的安装与使用(作业2)

    (本次作业要求来自:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2103) 分布式版本控制系统Git的安装与使用 一.安装Git b ...

  4. MySQL 单表优化

    一.表字段优化 1.整数类型尽量使用 TINYINT.SMALLINT.MEDIUM_INT 而不是INT,非负数要加上UNSIGNED 2.VARCHAR的长度分配要合理,不要过大 3.时间字段不超 ...

  5. FileUtils功能概述

    https://commons.apache.org/proper/commons-io/javadocs/api-release/org/apache/commons/io/FileUtils.ht ...

  6. 应用层协议及ip地址划分

    1.应用层协议 2.ip地址 3.子网划分及超网合并

  7. js screen

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

  8. LoadRunner12 Java Vuser API语法举例

    // 检查点 web.reg_find("Text=\"retCode\":\"0000\"",new String[]{"FAI ...

  9. LOJ115 无源汇有上下界可行流(上下界网络流)

    假设初始流为每条边的下界.但这样可能流量会不守恒,我们需要在上面加上一个附加流使流量守恒.只要让每个点开始的出/入流量与原初始流相等就可以求出附加流了.那么新建超源S超汇T,令degree[i]表示流 ...

  10. linq 分组取各组最大值

    static List<User> list1 = new List<User>() { new User(){id=1,name="张三"}, new U ...