Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- char rodcs[11];
- int rodnecs[10];
- int VelPol = 0;
- int VelPol1 = 0;
- cout << "Zadejte rodne cislo:" << endl;
- cin >> rodcs;
- int delka = strlen(rodcs);
- if (delka != 11)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- if (rodcs[6] != 47)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- for (int i = 0; i < 11; i++)
- {
- if (rodcs[i] != 47)
- {
- rodnecs[i] = rodcs[i] - 48;
- }
- }
- VelPol = rodnecs[0] + rodnecs[2] + rodnecs[4] + rodnecs[7] + rodnecs[9];
- VelPol1 = rodnecs[1] + rodnecs[3] + rodnecs[5] + rodnecs[8] + rodnecs[10];
- int vysledek = VelPol - VelPol1;
- if (vysledek % 11 != 0)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- if (rodnecs[2] == 5 || rodnecs[2] == 6)
- {
- rodnecs[2] = rodnecs[2] - 5;
- }
- if (rodnecs[2] != 0 && rodnecs[2] != 1)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- if (rodnecs[2] == 0)
- {
- if (rodnecs[3] < 1 || rodnecs[3] > 9)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- if (rodnecs[2] == 1)
- {
- if (rodnecs[3] < 0 || rodnecs[3] > 2)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- if (rodnecs[3] == 1 || rodnecs[3] == 3 || rodnecs[3] == 5 || rodnecs[3] == 7 || rodnecs[3] == 8 || rodnecs[3] == 10 || rodnecs[3] == 12)
- {
- if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 9)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- if (rodnecs[4] == 3)
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 1)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- }
- if (rodnecs[3] == 4 || rodnecs[3] == 6 || rodnecs[3] == 9 || rodnecs[3] == 11)
- {
- if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 9)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- if (rodnecs[4] == 3)
- {
- if (rodnecs[5] != 0)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- }
- if (rodnecs[3] == 2)
- {
- int prevod = 10*rodnecs[0] + rodnecs[1];
- if (prevod % 4 == 0)
- {
- if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 9)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- }
- else
- {
- if (rodnecs[4] == 0 || rodnecs[4] == 1)
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 9)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- if (rodnecs[4] == 2 )
- {
- if (rodnecs[5] < 0 || rodnecs[5] > 8)
- {
- cout << "Retezec neni rodnym cislem." << endl;
- return 0;
- }
- }
- }
- }
- cout << "Retezec muze byt rodnym cislem." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement