Skip to content

Instantly share code, notes, and snippets.

@brijeshb42
Created April 17, 2014 14:00
Show Gist options
  • Save brijeshb42/10985638 to your computer and use it in GitHub Desktop.
Save brijeshb42/10985638 to your computer and use it in GitHub Desktop.
#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