Advertisement
thesonpb

mật khẩu

Mar 30th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. string reverse(string s){
  6.     int a=s.length()+1;
  7.     char newstring[a];
  8.     for(int i=0; i<a; i++){
  9.         newstring[i]=s[a-2-i];
  10.     }
  11.     return newstring;
  12. }
  13. int main(){
  14.     int n;
  15.     cin >> n;
  16.     vector<string> a;
  17.     for(int i=0; i<n ;i++){
  18.         string s;
  19.         cin >> s;
  20.         a.push_back(s);
  21.     }
  22.     bool found=false;
  23.     for(int i=0; i<n-1; i++){
  24.         for(int j=i+1; j<n; j++){
  25.             if(reverse(a[i])==a[j]){
  26.                 int mid=(a[i].length()-1)/2;
  27.                 cout<<a[i].length()<<" "<<a[i][mid];
  28.                 found=true;
  29.                 break;
  30.             }
  31.         }
  32.         if(found) break;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement