当前位置: 首页 > news >正文

1050 String Subtraction (20)

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 10e4. 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.
aeiou

Sample Output:

Thy r stdnts.

题目大意:给出两个字符串,在第一个字符串中删除第二个字符串中出现过的所有字符并输出~
分析:用数组变量标记str2出现过的字符为,输出str1的时候检查是否被标记过。

#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
using namespace std;int main(void)
{#ifdef testfreopen("in.txt","r",stdin);//freopen("in.txt","w",stdout);clock_t start=clock();#endif //testchar s1[10010],s2[10010];fgets(s1,10010,stdin);//PAT不支持gets,要用fgets代替fgets(s2,10010,stdin);int num[300]={0};for(int i=0;s2[i];++i)num[s2[i]]=1;for(int i=0;s1[i];++i)if(num[s1[i]]==0)printf("%c",s1[i]);printf("\n");#ifdef testclockid_t end=clock();double endtime=(double)(end-start)/CLOCKS_PER_SEC;printf("\n\n\n\n\n");cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位#endif //testreturn 0;
}

 


http://www.mrgr.cn/news/75261.html

相关文章:

  • Git学习教程(更新中)
  • VTK知识学习(7)-纹理贴图
  • 如何在vscode 中打开新文件不覆盖上一个窗口
  • 【安全通信】告别信息泄露:搭建你的开源视频聊天系统briefing
  • 导游基础知识丨各民族民俗知识节选
  • 使用HAMi 进行gpu虚拟化
  • C++笔记
  • 多模态大模型(2)--BLIP
  • 【电子设计】按键LED控制与FreeRTOS
  • NGUI————按钮练习题
  • Towards Reasoning in Large Language Models: A Survey
  • Spring加载流程,Springboot自动装配原理
  • android开发
  • exo - 使用日常设备运行AI集群
  • 2024年09月CCF-GESP编程能力等级认证Python编程一级真题解析
  • 微信小程序-prettier 格式化
  • Diffusion Policy——斯坦福机器人UMI所用的扩散策略:从原理到其编码实现(含Diff-Control、ControlNet详解)
  • leetcode hot100【LeetCode 105.从前序与中序遍历序列构造二叉树】java实现
  • Web性能优化:从基础到高级
  • 二叉树的遍历(手动)
  • 一文了解Android的核心系统服务
  • 不宽的宽字符
  • 面试中如何回答“怎样实现 RPC 框架”的问题?
  • 高效的 JSON 处理库 json.cpp
  • ubuntu里面的gcc编译方法
  • 三维测量与建模笔记 - 特征提取与匹配 - 4.2 梯度算子、Canny边缘检测、霍夫变换直线检测