zoukankan      html  css  js  c++  java
  • 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);
       string aa,bb;
        int q=0;
        for(int i=1;i<=n;i++)
        {
            int sum=0;
            int a1[51]={0},b1[51]={0};
           getline(cin,aa);
           getline(cin,bb);
           //scanf("%s
    %s",aa,bb);
           int a=aa.length();
           int b=bb.length();
           if(a==0||b==0)
           {
               cout<<"Case #"<<i<<":  "<<max(a,b)<<endl;
    
           }
           //int sum=0;
           else{
           for(int k=0;k<a;k++)
           {
               for(int j=0;j<b;j++)
                    {
                        if(aa[k]==bb[j]&&a1[k]==0&&b1[j]==0)
                        {
                            a1[k]=1;
                            b1[j]=1;
                        }
                    }
    
           }
    
           for(int k=0;k<a;k++)
           {
               if(a1[k]==0)sum++;
           }
               for(int j=0;j<b;j++)
                    {
                        if(b1[j]==0)sum++;
    
                    }
    
           cout<<"Case #"<<i<<":  "<<sum<<endl;
           }
    
        }
    
    
        return 0;
    }
  • 相关阅读:
    学习进度06
    求最大子数组03
    js实现标签绑定回车事件
    ImageDown
    ImageUpload
    XMLProcess
    VideoConvert
    SmtpServerHelper
    SharpZip(压缩帮助类)
    SessionHelper
  • 原文地址:https://www.cnblogs.com/jin-nuo/p/5547567.html
Copyright © 2011-2022 走看看