Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- void poprawnosc(string pesel, int &a)
- {
- a=0;
- if(pesel.length()==11)
- {
- for(int i=0; i<pesel.length();i++)
- {
- if(isdigit(pesel[i]) != 0)
- a++;
- }
- }else;
- if(a!=11)
- cout<<"Podano bledny numer PESEL";
- }
- int data(string pesel)
- {
- string rok = pesel.substr(0,2);
- string miesiac = pesel.substr(2,2);
- string dzien = pesel.substr(4,2);
- cout<<"Data urodzenia: "<<dzien<<"."<<miesiac<<"."<<rok<<endl;
- }
- int year(string pesel)
- {
- int a=10* pesel[0];
- cout<<pesel[0]<<endl;
- cout<<a;
- int rok=10*pesel[0]+pesel[1];
- int miesiac=10*pesel[2]+pesel[3];
- if (miesiac > 80 && miesiac < 93)
- {
- rok += 1800;
- }
- else if (miesiac > 0 && miesiac < 13)
- {
- rok += 1900;
- }
- else if (miesiac > 20 && miesiac < 33)
- {
- rok += 2000;
- }
- else if (miesiac > 40 && miesiac < 53)
- {
- rok += 2100;
- }
- else if (miesiac > 60 && miesiac < 73)
- {
- rok += 2200;
- }
- return rok;
- }
- int month(string pesel)
- {
- int miesiac=10*pesel[2] +pesel[3];
- if (miesiac > 80 && miesiac < 93)
- {
- miesiac -= 80;
- }
- else if (miesiac > 20 && miesiac < 33)
- {
- miesiac -= 20;
- }
- else if (miesiac > 40 && miesiac < 53)
- {
- miesiac -= 40;
- }
- else if (miesiac > 60 && miesiac < 73)
- {
- miesiac -= 60;
- }
- if(miesiac > 0 && miesiac <13)
- {
- cout<<"Poprawny miesiac!"<<endl;
- }cout<<"Bledny miesiac!"<<endl;
- }
- void plec(string pesel)
- {
- cout<<"Plec: ";
- if(pesel[9]%2==0)
- {
- cout<<"kobieta"<<endl;}
- else cout<<"mezczyzna"<<endl;
- }
- int poprawnosc(string pesel)
- {
- int rok=pesel[0]&&pesel[1];
- cout<<rok;
- }
- int kontrola(string pesel)
- {
- int i=0;
- //1×a + 3×b + 7×c + 9×d + 1×e + 3×f + 7×g + 9×h + 1×i + 3×j + 1×k
- int a=1*pesel[0]+3*pesel[1]+7*pesel[2]+9*pesel[3]+1*pesel[4]+3*pesel[5]+7*pesel[6]+9*pesel[7]+1*pesel[8]+3*pesel[9]+1*pesel[10];
- if(a%10==0)cout<<"PESEL zgodny z suma kontrolna."<<endl;
- else cout<<"PESEL niezgodny z suma kontrolna!"<<endl;
- }
- int main()
- {
- int a,m=0;
- string pesel;
- cout<<"Podaj numer PESEL: ";
- getline(cin, pesel);
- poprawnosc(pesel,a);
- if(a==11)
- {
- year(pesel);
- month(pesel);
- data(pesel);
- plec(pesel);
- kontrola(pesel);
- }
- return( 0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement