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; }
?