Created
April 17, 2014 14:00
-
-
Save brijeshb42/10985638 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int main(int argc, char const *argv[]) | |
{ | |
string pin,tpin; | |
int *seq; | |
srand (time(NULL)); | |
cout<<"Enter your pin: "; | |
cin>>pin; | |
seq = new int[10]; | |
for(int i=0;i<10;i++){ | |
seq[i] = rand()%10; | |
cout<<i<<" "; | |
} | |
cout<<endl; | |
for(int i=0;i<10;i++){ | |
cout<<seq[i]<<" ";// = rand()%10; | |
} | |
cout<<endl; | |
cout<<"Enter your pin using these number: "; | |
cin>>tpin; | |
if(tpin.size()!=pin.size()){ | |
cout<<"Wrong PIN entered."; | |
} | |
for(int i=0;i<pin.size();i++){ | |
if(seq[(int)(pin[i]-'0')]!=(int)(tpin[i]-'0')){ | |
cout<<"Wrong PIN.\n"; | |
return 0; | |
} | |
} | |
cout<<"PIN matched!!! Hurray.\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment