Skip to content

Instantly share code, notes, and snippets.

@xkrsz
Created January 27, 2016 22:37
Show Gist options
  • Save xkrsz/19c68806ed03131cde88 to your computer and use it in GitHub Desktop.
Save xkrsz/19c68806ed03131cde88 to your computer and use it in GitHub Desktop.
PESEL
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <string>
#include <string.h>
using namespace std;
int main(){
string pesel;
cout << "Podaj PESEL: ";
cin >> pesel;
int rok = atoi(pesel.substr(0,2).c_str());
int miesiac = atoi(pesel.substr(2,2).c_str());
int dzien = atoi(pesel.substr(4,2).c_str());
int plecint = atoi(pesel.substr(9,1).c_str());
string plec;
if (plecint % 2 == 0){
plec = "K";
}
else{
plec = "M";
}
if (rok <= 16){
rok += 2000;
}
else{
rok += 1900;
}
cout << "Data urodzenia: " << dzien << "." << miesiac << "." << rok << endl;
cout << "Plec: " << plec << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment