Advertisement
Guest User

Не уходи постой, Рогозин

a guest
Nov 5th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <stdexcept>
  4. #define N 5
  5. using namespace std;
  6.  
  7. struct user
  8. {
  9.     int userID;
  10.     string userName;
  11.     int password;
  12.     string testPassword;
  13. };
  14.    
  15. int main()
  16. {
  17.  
  18.     int c;
  19.     user userList[N]={};
  20.    
  21.     for (int i = 0; i<N; ++i)
  22.     {
  23.         cout<<"Enter user ID: ";
  24.         cin>>userList[i].userID;
  25.         cout<<"Enter username: ";
  26.         cin>>userList[i].userName;
  27.         cout<<"Enter user password: ";
  28.         cin>>userList[i].password;
  29.     }
  30.     for (int i = 0; i < N; ++i)
  31.     {
  32.         c = userList[i].password;
  33.         while (c > 9)
  34.         {
  35.             c = c / 10;
  36.         }
  37.         if ((c == 1) && ((userList[i].password % 10) == 0))
  38.         {  
  39.             cout<<"Correct userdata: ";
  40.             cout << userList[i].userID <<" ";
  41.             cout << userList[i].userName <<" ";
  42.             cout << userList[i].password <<" \n";
  43.         }
  44.         else
  45.         {
  46.             cout<<"User #"<<i + 1<<" has incorrect password"<<"\n";
  47.         }
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement