Created
January 27, 2016 22:37
-
-
Save xkrsz/19c68806ed03131cde88 to your computer and use it in GitHub Desktop.
PESEL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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