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. Linux OpenSSH后门的添加与防范

    引言:相对于Windows,Linux操作系统的密码较难获取.不过很多Linux服务器配置了OpenSSH服务,在获取root权限的情况下,可以通过修改或者更新OpenSSH代码等方法,截取并保存其S ...

  2. 错误代码: 1054 Unknown column 'course' in 'field list'

    1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT stu_name, course, score FROM t_ ...

  3. Error creating bean with name 'com.you.user.dao.StudentDaoTest': Injection of autowired dependencies

    1.错误描述 七月 13, 2014 6:37:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBean ...

  4. net.at.json.JSONException

    1.错误描述 严重:Servlet.service() for servlet [clientServlet] in context with path [/User] threw exception ...

  5. JavaScript控制输入框只能输入非负正整数

    1.问题背景 问题:一个输入框,输入的是月份,保证输入的内容只能是非负正整数 2.JavaScript代码 function checkMonth() { $("month").k ...

  6. angular自定义过滤器操作实例

    //模块名字var filters = angular.module("customFilter",[]);//过滤器名字filters.filter("uniqueCa ...

  7. jquery 动态获得主机地址

    var curWwwPath=window.document.location.href; alert("curWwwPath"+curWwwPath); curWwwPath  ...

  8. spring mvc和swagger整合

    pom.xml 导入jar jar包 所属 备注 spring-core spring spring核心包 spring-expression spring spEl表达式 spring-beans ...

  9. 使用Spring-boot小结

    Spring-boot的特点是,通过注入的方式生成FsShell对象,来操作HDFS,其底层封装了HDFS的的shell命令 1. 添加Spring-boot依赖 pom.xml文件 <!--添 ...

  10. 【USACO4.2】草地排水Drainage Ditches(最大流)

    题目背景 在农夫约翰的农场上,每逢下雨,贝茜最喜欢的三叶草地就积聚了一潭水.这意味着草地被水淹没了,并且小草要继续生长还要花相当长一段时间.因此,农夫约翰修建了一套排水系统来使贝茜的草地免除被大水淹没 ...