zoukankan      html  css  js  c++  java
  • 百练-16年9月推免-B题-字符串判等

    2743:字符串判等

    总时间限制: 
    1000ms
     
    内存限制: 
    65536kB
    描述

    判断两个由大小写字母和空格组成的字符串在忽略大小写,且忽略空格后是否相等。

    输入
    两行,每行包含一个字符串。
    输出
    若两个字符串相等,输出YES,否则输出NO。
    样例输入
    a A bb BB ccc CCC
    Aa BBbb CCCccc
    
    样例输出
    YES

    #include <iostream>
    #include <algorithm>
    #include <stdio.h>
    #include <string>
    #include <ctype.h>
    
    using namespace std;
    
    int main()  {
        char a[101];
        char b[101];
        gets(a);    gets(b);
        string aa, bb;
        aa = a; bb = b;
    
        char aaa[101];  char bbb[101];
    
        for(int i = 0; i < aa.size(); i++)  {
            aa[i] = tolower(aa[i]);
        }
        for(int i = 0; i < bb.size(); i++)  {
            bb[i] = tolower(bb[i]);
        }
    
        string f = " ";
        int t = aa.find(f, 0);
        while(t != string::npos)    {
            aa.erase(t, 1);
            t = aa.find(f, 0);
        }
    
        t = bb.find(f, 0);
        while(t != string::npos)    {
            bb.erase(t, 1);
            t = bb.find(f, 0);
        }
    
        if(aa == bb)    printf("YES");
        else    printf("NO");
    
        return 0;
    }
  • 相关阅读:
    BSGS算法(大步小步算法)
    UVA-11426【GCD
    UVA-1637【Double Patience】(概率dp)
    UVA-11174【Stand in a Line】
    About
    51nod 1355 斐波那契的最小公倍数
    CodeForces
    CodeForces
    CodeForces
    CodeForces 901C Bipartite Segments
  • 原文地址:https://www.cnblogs.com/QingHuan/p/7105044.html
Copyright © 2011-2022 走看看