/** (c) 2012 Michał (Foxbond) Chraniuk */
#include <stdlib.h>
#include <stdio.h>
#include <cstring> //strlen
#include <conio.h> //_getch
#include <time.h>
void cls () { system("cls"); }
int charToInt (char znak){
return (int)znak;
}
bool generate (char *_buf, char plec, int ile){
if (strlen(_buf) != 10){
return false;
}
if (plec != 'k' && plec != 'm' && plec != 'K' && plec != 'M'){
return false;
}
if (ile < 1 || ile > 1000){
return false;
}
int dzien = charToInt(_buf[0])*10 + charToInt(_buf[1])*10;
printf("%c (%i) == %i", _buf[0], _buf[0], charToInt(_buf[0]));
srand (time(NULL));
}
int main (){
char _buf[200];
char _plec = 'k';
int _ile = 1;
char cont = 't';
do {
printf("Podaj date (dd-mm-rrrr):");
scanf("%s", _buf);
printf("\nPodaj plec (m/k):");
_plec = _getch();
printf("\nIle numerów chcesz wygenerowac?:");
scanf("%i", _ile);
if (!generate(_buf, _plec, _ile)){
printf("\nNie udalo sie wygenerowac numerow pesel! (np.: podano zle dane)");
}
printf("\nJeszcze raz? (t/n):");
cont = _getch();
cls();
}while(cont == 't' || cont == 'T');
//system("PAUSE");
return 0;
}
> Back