poj 2681 字符串
http://poj.org/problem?id=2681
给你任意长度的字符串,找出两串字符中不相同的字符个数(总数)
#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n;
scanf("%d\n",&n);
string aa,bb;
int q=;
for(int i=;i<=n;i++)
{
int sum=;
int a1[]={},b1[]={};
getline(cin,aa);
getline(cin,bb);
//scanf("%s\n%s",aa,bb);
int a=aa.length();
int b=bb.length();
if(a==||b==)
{
cout<<"Case #"<<i<<": "<<max(a,b)<<endl; }
//int sum=0;
else{
for(int k=;k<a;k++)
{
for(int j=;j<b;j++)
{
if(aa[k]==bb[j]&&a1[k]==&&b1[j]==)
{
a1[k]=;
b1[j]=;
}
} } for(int k=;k<a;k++)
{
if(a1[k]==)sum++;
}
for(int j=;j<b;j++)
{
if(b1[j]==)sum++; } cout<<"Case #"<<i<<": "<<sum<<endl;
} } return ;
}
poj 2681 字符串的更多相关文章
- POJ 1200 字符串HASH
题目链接:http://poj.org/problem?id=1200 题意:给定一个字符串,字符串只有NC个不同的字符,问这个字符串所有长度为N的子串有多少个不相同. 思路:字符串HASH,因为只有 ...
- poj 3461 字符串单串匹配--KMP或者字符串HASH
http://poj.org/problem?id=3461 先来一发KMP算法: #include <cstdio> #include <cstring> #include ...
- poj 2503(字符串)
http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 # ...
- poj 3981 字符串替换
字符串替换 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10871 Accepted: 5100 Descriptio ...
- poj 2503 字符串hash
题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<i ...
- poj 1200字符串hash
题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...
- poj 2774 字符串哈希求最长公共子串
Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- POJ 3080 (字符串水题) Blue Jeans
题意: 找出这些串中最长的公共子串(长度≥3),如果长度相同输出字典序最小的那个. 分析: 用库函数strstr直接查找就好了,用KMP反而是杀鸡用牛刀. #include <cstdio> ...
- POJ 2681
#include<iostream> #include<stdio.h> #include<string> #include<algorithm> #d ...
随机推荐
- ssh禁止密码登录
1.root用户登陆后,运行以下第一句指令,其他根据提示进行输入: ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file ...
- org.apache.jasper.JasperException: /pages/path.jsp
1.错误描述 三月 15, 2015 8:56:37 下午 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least o ...
- PyCharm运行报编码错误
运行报如下错误: SyntaxError: Non-ASCII character '\xe8' in file /home/ubuntu/code/201803091253-text.py on l ...
- 爬虫工具fiddle在firefox浏览器中的使用
1.fiddle工作原理 浏览器与服务器之间通过建立TCP连接以HTTP协议进行通信,默认通过自己发送HTTP(或HTTPS)请求到服务器. 使用Fiddler之后,浏览器像目标服务器发送的请求都会经 ...
- Mybatis【逆向工程,缓存,代理】知识要点
前言 本文主要讲解Mybatis的以下知识点: Mybatis缓存 一级缓存 二级缓存 与Ehcache整合 Mapper代理 使用Mapper代理就不用写实现类了 逆向工程 自动生成代码 Mybat ...
- Gulp-自动化编译sass和pug文件
突然发现在我博客文章中,缺少这一块的记录,那我就补一篇吧. gulp的环境配置和安装:http://www.cnblogs.com/padding1015/p/7162024.html 这里就补充一篇 ...
- 好用的sitemap生成器—GY SiteMap
好用的sitemap生成器-GY SiteMap 下载地址:http://www.wyxxw.cn/download-detail-6-8-14.html 网站地图可以更好的帮助搜索引擎抓取.收录网站 ...
- C++堆栈详解
一.预备知识-程序的内存分配 一个由c/C++编译的程序占用的内存分为以下几个部分 1.栈区(stack)- 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等.其操作方式类似于数据结构中的栈. ...
- 【MyBatis源码分析】Configuration加载(上篇)
config.xml解析为org.w3c.dom.Document 本文首先来简单看一下MyBatis中将config.xml解析为org.w3c.dom.Document的流程,代码为上文的这部分: ...
- 【Spring源码分析】AOP源码解析(上篇)
前言 前面写了六篇文章详细地分析了Spring Bean加载流程,这部分完了之后就要进入一个比较困难的部分了,就是AOP的实现原理分析.为了探究AOP实现原理,首先定义几个类,一个Dao接口: pub ...