Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <stdexcept>
- #define N 5
- using namespace std;
- struct user
- {
- int userID;
- string userName;
- int password;
- string testPassword;
- };
- int main()
- {
- int c;
- user userList[N]={};
- for (int i = 0; i<N; ++i)
- {
- cout<<"Enter user ID: ";
- cin>>userList[i].userID;
- cout<<"Enter username: ";
- cin>>userList[i].userName;
- cout<<"Enter user password: ";
- cin>>userList[i].password;
- }
- for (int i = 0; i < N; ++i)
- {
- c = userList[i].password;
- while (c > 9)
- {
- c = c / 10;
- }
- if ((c == 1) && ((userList[i].password % 10) == 0))
- {
- cout<<"Correct userdata: ";
- cout << userList[i].userID <<" ";
- cout << userList[i].userName <<" ";
- cout << userList[i].password <<" \n";
- }
- else
- {
- cout<<"User #"<<i + 1<<" has incorrect password"<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement