1050. String Subtraction (20)
时间限制10 ms
内存限制65536 kB
代码长度限制16000 B
判题程序Standard作者CHEN, Yue
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However, it might not be that simple to do it fast.
Input Specification:
Each input file contains one test case. Each case consists of two lines which gives S1 and S2, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.
Output Specification:
For each test case, print S1 - S2 in one line.
Sample Input:They are students. aeiouSample Output:Thy r stdnts.输入两个行句子
把第一行中出现在第二行的符号去掉
最后输出处理完的第一行
s2.insert(0, 1, s1[index]) 把s1[index]插入原来s2[0]的前面;插入一次;
评测结果
时间 | 结果 | 得分 | 题目 | 语言 | 用时(ms) | 内存(kB) | 用户 |
---|---|---|---|---|---|---|---|
8月11日 21:45 | 答案正确 | 20 | 1050 | C++ (g++ 4.7.2) | 3 | 308 | datrilla |
测试点
测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
---|---|---|---|---|
0 | 答案正确 | 1 | 308 | 12/12 |
1 | 答案正确 | 2 | 308 | 3/3 |
2 | 答案正确 | 1 | 308 | 2/2 |
3 | 答案正确 | 3 | 308 | 3/3 |
#include<iostream> #include<string> #define LEn 256 /*ACSII 7bit+1bit奇偶校验 =2^8=256*/ using namespace std; int main() { bool InS2[LEn] = {false}; string s1, s2; int index; getline(cin,s1); getline(cin, s2); index = 0; while (s2[index])InS2[s2[index++]] = true; s2.clear(); for (index = s1.size() - 1; index >= 0; index--) if(!InS2[s1[index]])s2.insert(0, 1, s1[index]); cout << s2 << endl; system("pause"); return 0; }