Can you raed it croretcly?
生活随笔
收集整理的這篇文章主要介紹了
Can you raed it croretcly?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://acm.hdu.edu.cn/showproblem.php?pid=6543
題意:如果單詞的首字母和最后一個字母是正確的,只是交換其他字母,人類可以自動糾正單詞的拼寫。當兩個字符串相同時輸出“Equal”; 輸出“是”時可以更正,否則輸出“否”。
題解:輸入兩個字符串,如果兩者一樣則輸出Equal,不一樣則判斷字符串首尾字母是否相同,中間字母對應個數是否相同,直接輸出結果。
C++版本一
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=300+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; string str1,str2; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);while(cin>>str1){cin>>str2;memset(a,0,sizeof(a));if(str1==str2){cout<<"Equal"<<endl;}else{flag=1;for(int i=0;i<str1.size();i++)a[str1[i]-97]++;for(int i=0;i<str2.size();i++)a[str2[i]-97]--;for(int i=0;i<26;i++)if(a[i])flag=0;cout<<(flag&&str1[0]==str2[0]&&str1[str1.size()-1]==str2[str2.size()-1]?"Yes":"No")<<endl;}//scanf("%d",&n);}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }總結
以上是生活随笔為你收集整理的Can you raed it croretcly?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SSY and JLBD
- 下一篇: 方格取数(1)