Advertisement
Guest User

Hovno Kod jak zmrd

a guest
Nov 13th, 2014
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char rodcs[11];
  10.     int rodnecs[10];
  11.     int VelPol = 0;
  12.     int VelPol1 = 0;
  13.     cout << "Zadejte rodne cislo:" << endl;
  14.     cin >> rodcs;
  15.  
  16.     int delka = strlen(rodcs);
  17.  
  18.     if (delka != 11)
  19.     {
  20.         cout << "Retezec neni rodnym cislem." << endl;
  21.         return 0;
  22.     }
  23.  
  24.     if (rodcs[6] != 47)
  25.     {
  26.         cout << "Retezec neni rodnym cislem." << endl;
  27.         return 0;
  28.     }
  29.  
  30.     for (int i = 0; i < 11; i++)
  31.     {
  32.         if (rodcs[i] != 47)
  33.         {
  34.             rodnecs[i] = rodcs[i] - 48;
  35.         }
  36.     }
  37.     VelPol = rodnecs[0] + rodnecs[2] + rodnecs[4] + rodnecs[7] + rodnecs[9];
  38.     VelPol1 = rodnecs[1] + rodnecs[3] + rodnecs[5] + rodnecs[8] + rodnecs[10];
  39.  
  40.     int vysledek = VelPol - VelPol1;
  41.  
  42.     if (vysledek % 11 != 0)
  43.     {
  44.         cout << "Retezec neni rodnym cislem." << endl;
  45.         return 0;
  46.     }
  47.     if (rodnecs[2] == 5 || rodnecs[2] == 6)
  48.     {
  49.         rodnecs[2] = rodnecs[2] - 5;
  50.     }
  51.     if (rodnecs[2] != 0 && rodnecs[2] != 1)
  52.     {
  53.        cout << "Retezec neni rodnym cislem." << endl;
  54.        return 0;
  55.     }
  56.     if (rodnecs[2] == 0)
  57.     {
  58.         if (rodnecs[3] < 1 || rodnecs[3] > 9)
  59.         {
  60.         cout << "Retezec neni rodnym cislem." << endl;
  61.         return 0;
  62.         }
  63.     }
  64.     if (rodnecs[2] == 1)
  65.     {
  66.         if (rodnecs[3] < 0 || rodnecs[3] > 2)
  67.         {
  68.         cout << "Retezec neni rodnym cislem." << endl;
  69.         return 0;
  70.         }
  71.     }
  72.     if (rodnecs[3] == 1 || rodnecs[3] == 3 || rodnecs[3] == 5 || rodnecs[3] == 7 || rodnecs[3] == 8 || rodnecs[3] == 10 || rodnecs[3] == 12)
  73.  
  74.     {
  75.         if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
  76.         {
  77.             if (rodnecs[5] < 0 || rodnecs[5] > 9)
  78.             {
  79.             cout << "Retezec neni rodnym cislem." << endl;
  80.             return 0;
  81.             }
  82.         }
  83.         if (rodnecs[4] == 3)
  84.         {
  85.             if (rodnecs[5] < 0 || rodnecs[5] > 1)
  86.             {
  87.             cout << "Retezec neni rodnym cislem." << endl;
  88.             return 0;
  89.             }
  90.         }
  91.     }
  92.     if (rodnecs[3] == 4 || rodnecs[3] == 6 || rodnecs[3] == 9 || rodnecs[3] == 11)
  93.  
  94.     {
  95.         if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
  96.         {
  97.             if (rodnecs[5] < 0 || rodnecs[5] > 9)
  98.             {
  99.             cout << "Retezec neni rodnym cislem." << endl;
  100.             return 0;
  101.             }
  102.         }
  103.         if (rodnecs[4] == 3)
  104.         {
  105.             if (rodnecs[5] != 0)
  106.             {
  107.             cout << "Retezec neni rodnym cislem." << endl;
  108.             return 0;
  109.             }
  110.         }
  111.     }
  112.     if (rodnecs[3] == 2)
  113.     {
  114.         int prevod = 10*rodnecs[0] + rodnecs[1];
  115.         if (prevod % 4 == 0)
  116.         {
  117.             if (rodnecs[4] == 0 || rodnecs[4] == 1 || rodnecs[4] == 2 )
  118.             {
  119.                 if (rodnecs[5] < 0 || rodnecs[5] > 9)
  120.                 {
  121.                 cout << "Retezec neni rodnym cislem." << endl;
  122.                 return 0;
  123.                 }
  124.             }
  125.         }
  126.         else
  127.         {
  128.             if (rodnecs[4] == 0 || rodnecs[4] == 1)
  129.             {
  130.                 if (rodnecs[5] < 0 || rodnecs[5] > 9)
  131.                 {
  132.                 cout << "Retezec neni rodnym cislem." << endl;
  133.                 return 0;
  134.                 }
  135.             }
  136.             if (rodnecs[4] == 2 )
  137.             {
  138.                 if (rodnecs[5] < 0 || rodnecs[5] > 8)
  139.                 {
  140.                 cout << "Retezec neni rodnym cislem." << endl;
  141.                 return 0;
  142.                 }
  143.             }
  144.         }
  145.     }
  146.  
  147.     cout << "Retezec muze byt rodnym cislem." << endl;
  148.  
  149.     return 0;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement