(erase) Mispelling4 hdu1984
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的更多相关文章
- c++ 列表删除元素(erase)
#include <list> #include <iostream> #include <iterator> using namespace std; int m ...
- Linux学习笔记(11)软件包管理
Linux中的软件包分为源码包(脚本安装包)及二进制包(RPM包.系统默认包).其中源码包的优点是: 1)源码包是开源的,如果有足够的能力,可以修改源代码: 2)可自由选择所需的功能: 3)源码包需编 ...
- c++字符串详解(转)
之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至是 ...
- (C++)String的用法
(转自http://www.cnblogs.com/yxnchinahlj/archive/2011/02/12/1952550.html) 之所以抛弃char*的字符串而选用C++标准程序库中的st ...
- Linux 基础(3)
Linux 基础(三) rpm与yum学习 本篇分享一下自己学习rpm和yum过程中的一些心得,自己在使用yum过程中由于自己的虚拟机网络的问题在学习这一块品尝到不少苦头,还望学习这块的盆友先检查一下 ...
- linux操作系统基础篇(五)
Linux网络以及rpm安装yum源的配置 1.Linux网络 1. 使用ifconfig命令来维护网络1) fconfig命令的功能:显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址.2) ...
- linux学习笔记整理(七)
第八章 Centos7软件包的管理与安装本节所讲内容:8.1 使用rpm命令-安装-查看-卸载-rpm软件包8.2 yum管理软件包8.3 实战tar源码包管理-srpm源码包安装方法 8.1 软件包 ...
- C++ string(转)
C++中string是标准库中一种容器,相当于保存元素类型为char的vector容器(自己理解),这个类提供了相当丰富的函数来完成对字符串操作,以及与C风格字符串之间转换,下面是对string一些总 ...
- NAND flash学习所获----(Zac)
Nand Falsh外围电路:peripheral circuit 1.Nand flash里至少有2个state Machine(controller),即2个主控. 一个主控:负责处理前端事情. ...
随机推荐
- C_数据结构_递归实现累加
# include <stdio.h> long sum(int n) { //用递归实现: ) ; else ) + n; /* 用for循环实现: long s = 0; int i; ...
- Python 安装 OpenCV 遇到的问题
从 python下了 opencv_python-3.3.1+contrib-cp36-cp36m-win_amd64.whl [python 3.6 os win10 64 IDE Pychar ...
- Essential Netty in Action 《Netty 实战(精髓)》读书笔记一
NIO 最初是为 New Input/Output 的缩写.然而,Java 的 API 已经存在足够长的时间,它不再是新的.现在普遍使用的缩写来表示Nonblocking I/O (非阻塞 I/O). ...
- Win10删除微软拼音输入法的方法
1. 控制面板 2.更换输入法 选择添加语言 添加上英文输入法之后 进行上下移动 然后删除中文输入法即可 需要在英文的语言栏里面添加-选项-增加输入法 然后删除中文即可.
- Vue 初识Vue
<!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...
- SpringBoot(十七)_springboot跨域处理
本文转自:Vi的技术博客 什么是跨域 首先,我们需要了解一下一个URL是怎么组成的: // 协议 + 域名(子域名 + 主域名) + 端口号 + 资源地址 http: + // + www.baidu ...
- Hbase之Java API远程访问Kerberos认证
HbaseConnKer.java package BigData.conn; import BigData.utils.resource.ResourcesUtils; import org.apa ...
- python之hasattr、getattr和setattr函数
hasattr函数使用方法 # hasattr函数使用方法 # hasattr(object,attr) # 判断一个对象里是否有某个属性或方法,返回布尔值,有为True,否则False class ...
- 英国电信反悔华为是唯一真正的5G供应商
导读 英国电信反悔华为是唯一真正的5G供应商 英国电信的一位发言人表示,该公司目前正「从我们自 2006 年以来实施的网络架构原则中,从我们的 3G 和 4G 网络核心提取华为设备」. 英国电信已经不 ...
- git如何拉取指定分支的代码
问题背景: 新项目还在开发阶段,没有正式对外发布,所以开发同事合并代码到develop上(或者其他名称分支上),而不是到master分支上 通过git拉取代码的时候,默认拉取的是master分支,如下 ...