1093 字符串A+B

在这里插入图片描述

solution

#include<iostream>
#include<string>
using namespace std;
const int maxn = 135;
int flag[maxn] = {0};
void printC(string s){
	for(int i = 0; i < s.size(); i++){
		if(!flag[s[i]]){
			cout << s[i];
			flag[s[i]] = 1;
		}
	}
}
int main(){
	string a, b;
	getline(cin, a);
	getline(cin, b);
	printC(a);
	printC(b);
	return 0;
}

or

#include<iostream>
#include<string>
using namespace std;
const int maxn = 135;
int flag[maxn] = {0};
int main(){
	string a, b;
	getline(cin, a);
	getline(cin, b);
	a = a + b;
	for(int i = 0; i < a.size(); i++){
		if(!flag[a[i]]){
			cout << a[i];
			flag[a[i]] = 1;
		}
	}
	return 0;
}

相关推荐

  1. P1098 [NOIP2007 提高组] 字符串的展开

    2024-04-27 19:04:02       30 阅读
  2. 字符串AC自动机

    2024-04-27 19:04:02       56 阅读
  3. Leetcode的AC指南 —— 字符串:344. 反转字符串

    2024-04-27 19:04:02       68 阅读
  4. 字符串

    2024-04-27 19:04:02       31 阅读
  5. mysql error: #1093

    2024-04-27 19:04:02       58 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-27 19:04:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-27 19:04:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-27 19:04:02       82 阅读
  4. Python语言-面向对象

    2024-04-27 19:04:02       91 阅读

热门阅读

  1. Llama改进之——均方根层归一化RMSNorm

    2024-04-27 19:04:02       33 阅读
  2. Windows自动化重启python脚本

    2024-04-27 19:04:02       32 阅读
  3. 4.19作业 驱动开发

    2024-04-27 19:04:02       35 阅读
  4. 面试经典150题——最后一个单词的长度

    2024-04-27 19:04:02       29 阅读
  5. 容器内的服务和docker 映射的服务

    2024-04-27 19:04:02       29 阅读
  6. Python 潮流周刊#48:Python 3.14 的发布计划

    2024-04-27 19:04:02       28 阅读
  7. 2023-2024年6G行业报告合集(精选33份)

    2024-04-27 19:04:02       37 阅读
  8. C++问题笔记

    2024-04-27 19:04:02       32 阅读
  9. filebeat 设置elasticsearch索引的 max_result_window

    2024-04-27 19:04:02       30 阅读
  10. LeetCode刷题笔记第104题:二叉树的最大深度

    2024-04-27 19:04:02       33 阅读