PAT甲级1035 Password:[C++题解]字符串修改
生活随笔
收集整理的這篇文章主要介紹了
PAT甲级1035 Password:[C++题解]字符串修改
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 題目分析
- 題目鏈接
題目分析
題目重述:
題目分析:
ac代碼
#include<bits/stdc++.h> using namespace std;string Name,Code;typedef pair< string ,string> PII;vector<PII> vec;int main(){int n;cin>>n;int N=n;int cntM =0;string suffix = "01lO";string replace="%@Lo";while(n--){string name,code;cin>>name>>code;bool flag =true; //沒改過for(int i=0;i<code.size();i++){int pos=suffix.find(code[i]);if(pos!= -1){code[i]=replace[pos];flag =false;}}if(!flag) cntM++,vec.push_back({name,code});}if(cntM){ //有修改過的cout<< cntM<<endl;for(auto c:vec){cout<< c.first<<" "<<c.second<<endl;}}else{if(N!=1)cout<<"There are "<< N <<" accounts and no account is modified";elsecout<<"There is "<< N<<" account and no account is modified";} }題目鏈接
PAT甲級1035 Password
總結
以上是生活随笔為你收集整理的PAT甲级1035 Password:[C++题解]字符串修改的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PAT甲级1006 Sign In an
- 下一篇: PAT甲级1036 Boys vs Gi