[ create a new paste ] login | about

Link: http://codepad.org/E3r4IqSB    [ raw code | output | fork ]

C++, pasted on Jan 11:
#include <iostream>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	char ident[30];
	cout<<"Ident = ";
	cin>>ident;
	int idLen=strlen(ident);

	char num[]="qwertyuiopasdfghjklzxcvbnm";
	char sym[]="QWERTYUIOPASDFGHJKLZXCVBNM";
   
	srand(time(0));

	//длина пароля
    int passLen=12+rand()%10; // Требуемое кол-во символов - 11
	char *password=new char[passLen]; // строка-пароль
	password[0]=nym[rand()%12]; // b1,b2 - случайные символы из множества {!,”,#,$,%,&,’,(,),*}.x
    password[1]=nym[rand()%12];

	int Q=strlen(ident)%8;	

	for(int i=2;i<Q;i++)
	{
		if(rand()%2)
			password[i]=(char)(65+rand()%16);
		else
			password[i]=(char)(65+rand()%16); // b3,...,b3+Q - случайные малые буквы русского алфавита, где Q=Nmod8
	}

	for(int i=Q;i<passLen;i++)
		password[i]=num[rand()%11]; //b4+Q,...,b11 - случайные цифры.

	password[passLen]='\0';

	cout<<"ident = "<<ident<<"\npass = "<<password<<endl;
  
}


Output:
1
2
3
In function 'int main()':
Line 22: error: 'nym' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: