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 字符串的更多相关文章

  1. POJ 1200 字符串HASH

    题目链接:http://poj.org/problem?id=1200 题意:给定一个字符串,字符串只有NC个不同的字符,问这个字符串所有长度为N的子串有多少个不相同. 思路:字符串HASH,因为只有 ...

  2. poj 3461 字符串单串匹配--KMP或者字符串HASH

    http://poj.org/problem?id=3461 先来一发KMP算法: #include <cstdio> #include <cstring> #include ...

  3. poj 2503(字符串)

    http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 # ...

  4. poj 3981 字符串替换

    字符串替换 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10871   Accepted: 5100 Descriptio ...

  5. poj 2503 字符串hash

    题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<i ...

  6. poj 1200字符串hash

    题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...

  7. poj 2774 字符串哈希求最长公共子串

    Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...

  8. POJ 3080 (字符串水题) Blue Jeans

    题意: 找出这些串中最长的公共子串(长度≥3),如果长度相同输出字典序最小的那个. 分析: 用库函数strstr直接查找就好了,用KMP反而是杀鸡用牛刀. #include <cstdio> ...

  9. POJ 2681

    #include<iostream> #include<stdio.h> #include<string> #include<algorithm> #d ...

随机推荐

  1. H3C无线路由器安装与设置

    一.电脑与路由器的连接利用一根cat5e网线一头连接到电脑上笔记本或台式机都可以,另一头连接到无线路由器的LAN口任意LAN口都可以二.设置无线路由器完成路由器安装与电脑连接后,接下首次使用就需要设置 ...

  2. 【mongodb系统学习之十一】mongodb删除数据

    十一.mongodb删除数据: 1).删除全部文档:remove,语法db.collectionName.remove({}):小括号里边必须要有条件,否则不成功:如果只是一个空的{},则会删除集合内 ...

  3. jquery Dialog弹框插件

    function Dialog(options) { var defaults = { // 默认值. title: '', // 标题文本,若不想显示title请通过CSS设置其display为no ...

  4. Linux集群问题~浅谈

    系统扩展的方式 # scale up 向上扩展 # scale out 向外扩展 集群类型 LB 负载均衡集群 Load Balancing HA 高可用集群 High Availability HP ...

  5. order调用mdp

    Java代码 else            {                crmMessageService[A1] .applyAsync(crmMdpRequest); } public v ...

  6. Stanford CS224N 第二课: word2vec详细介绍

    word2vec模型 word2vec 模型有两种: Continuous Skip-gram Model 和 Continuous Bag of Words Model (CBOW). 本文主要讲解 ...

  7. 【MyBatis源码分析】Configuration加载(上篇)

    config.xml解析为org.w3c.dom.Document 本文首先来简单看一下MyBatis中将config.xml解析为org.w3c.dom.Document的流程,代码为上文的这部分: ...

  8. 创建Maven项目时提示web.xml is missing and <failOnMissingWebXml> is set to true错误解决方案

    1. 右键点击Deployment Descriptor 2. 选择Generate Deployment Descriptor Stub P.S.下面顺便提一个小技巧: 创建动态web时先右键项目, ...

  9. 大数据(1):基于sogou.500w.utf8数据的MapReduce程序设计

    环境:centos7+hadoop2.5.2 1.使用ECLIPS具打包运行WORDCOUNT实例,统计莎士比亚文集各单词计数(文件SHAKESPEARE.TXT). ①WorldCount.java ...

  10. animation,transform属性

    animation属性 使用@keyfarmes属性开启动画步骤 结构体:@keyfarmes name{ from{ } to{ } } @keyfarmes name{ 0%{ } 50%{ } ...