Title:
Set
A=(1,3, a, s, t, i} represent alphanumeric characters permitted to be used to
set the password of length 4. Write C/C++ program to generate all possible
passwords.
Program:
#include<iostream>
using namespace std;
class password
{
char a[6]={'1','3', 'a','s','t','i'};
int n,count;
public:
password()
{
n=6;
count=0;
}
void display()
{
for(int i=0 ; i<n ; i++)
{
for(int j=0 ; j<n ; j++)
{
for(int k=0 ; k<n ; k++)
{
for(int l=0 ; l<n ; l++)
{
cout<<"\n"<<a[i]<<a[j]<<a[k]<<a[l];
count++;
}
}
}
}
cout<<"\nNo. of Combinatons : "<<count;
}
};
int main()
{
password p;
p.display();
return 0;
}
Output:
1111
1113
111a
111s
|
|
|
iiia
iiis
iiit
iiii
No. of Combinatons : 1296
No comments:
Post a Comment