SabirSazzad

Phone Book mapping

Mar 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. struct phoneBook
  4. {
  5.     char name[100];
  6.     char name2[100];
  7.     int number;
  8. };
  9.  
  10.  
  11. int main ()
  12. {
  13.     int i,j,x=0,n;
  14.     cin >> n;
  15.     struct phoneBook friends[n];
  16.  
  17.     for(i=0; i<n; i++)
  18.     {
  19.         cin >> friends[i].name >> friends[i].number;
  20.     }
  21.     for(i=0; i<n; i++)
  22.     {
  23.         cin >> friends[i].name2;
  24.     }
  25.  
  26.     for(i=0; i<n; i++)
  27.     {
  28.         for(j=0; friends[i].name[j] != '\0'; j++)
  29.         {
  30.             if(friends[i].name[j] != friends[i].name2[j])
  31.             {
  32.                x++;
  33.             }
  34.         }
  35.         if (x==0)
  36.         {
  37.             cout << friends[i].name << "=" << friends[i].number << "\n";
  38.         }
  39.         else
  40.         {
  41.             cout << "Not found" << "\n";
  42.         }
  43.         x = 0;
  44.  
  45.     }
  46.  
  47.  
  48.     return 0;
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment