首页 > 代码库 > PAT 1034

PAT 1034

注意看后面output的要求OTL

陈越姥姥我都不太想吐槽你了... 

 

 1 #include <vector> 2 #include <iostream> 3 #include <string> 4 #include <fstream> 5  6 #define OJ 7  8 #ifdef OJ 9 #define fin cin10 #endif11 12 using namespace std;13 14 class User{15 public:16     User(){17         modified = false;18     }19 20     string name;21     string passwd;22     bool modified;23 };24 25 vector<User> users;26 27 int main(){28 #ifndef OJ29     ifstream fin;30     fin.open("in.data");31 #endif32 33 34     int N;35     fin >> N;36 37     for (int i = 0; i < N; i++){38         User user;39         fin >> user.name >> user.passwd;40         users.push_back(user);41     }42 43     int mod_cnt = 0;44     for (int i = 0; i < N; i++){45         User &user = users[i];46         string &str = user.passwd;47         for (int j = 0; j < str.size(); j++){48             bool modified = true;49             if (str[j] == 1)50                 str[j] = @;51             else if (str[j] == 0)52                 str[j] = %;53             else if (str[j] == l)54                 str[j] = L;55             else if (str[j] == O)56                 str[j] = o;57             else58                 modified = false;59 60             user.modified |= modified;61         }62         if (user.modified)63             mod_cnt++;64     }65 66     if (mod_cnt == 0){67         cout << "There " << (N == 1 ? "is " : "are ") << N << (N == 1 ? " account" : " accounts") << " and no account is modified" << endl;68 69         return 0;70     }71 72     cout << mod_cnt << endl;73     for (int i = 0; i < N; i++){74         User &user = users[i];75         if (user.modified){76             cout << user.name << " " << user.passwd << endl;77         }78     }79 80     return 0;81 }

 

PAT 1034