fork(6) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string formularz, imie, nazwisko, rok, miesiac, dzien;
  7. int dlugoscStringa, dlImie, dlNazwisko, Srednik1_int,Srednik2_int, rok_int, miesiac_int, dzien_int;
  8. size_t Srednik1, Srednik2;
  9. bool imieOK, nazwiskoOK, dataOK;
  10.  
  11. int main()
  12. {
  13.  
  14. while(getline(cin,formularz))
  15. {
  16.  
  17. imieOK=0;
  18. nazwiskoOK = 0;
  19. dataOK = 0;
  20.  
  21. dlugoscStringa=formularz.length();
  22.  
  23. Srednik1=formularz.find(";");
  24. Srednik2=formularz.find(";",Srednik1+1);
  25.  
  26. Srednik1_int=int(Srednik1);
  27. Srednik2_int=int(Srednik2);
  28.  
  29. imie = formularz.substr(6,Srednik1_int-6);
  30.  
  31. nazwisko = formularz.substr(Srednik1_int+12,Srednik2_int-Srednik1_int-12);
  32.  
  33. rok = formularz.substr(Srednik2_int+12,4);
  34.  
  35. miesiac = formularz.substr(Srednik2_int+17,2);
  36.  
  37. dzien = formularz.substr(Srednik2_int+20,2);
  38.  
  39. dlImie=imie.length();
  40. dlNazwisko=nazwisko.length();
  41.  
  42. //imie
  43.  
  44. if((imie[0]>=65)and(imie[0]<=90))
  45. {
  46. for (int i=1;i<dlImie;i++)
  47. {
  48. if((imie[i]>=97)and(imie[i]<=122))
  49. imieOK=true;
  50. else
  51. {
  52. imieOK = false;
  53. break;
  54. }
  55.  
  56. }
  57. }
  58. else
  59. imieOK = false;
  60.  
  61. //nazwisko
  62. if((nazwisko[0]>=65)and(nazwisko[0]<=90))
  63. {
  64. for (int i=1;i<dlNazwisko;i++)
  65. {
  66. if((nazwisko[i]>=97)and(nazwisko[i]<=122))
  67. {
  68. nazwiskoOK = true;
  69. }
  70. else
  71. {
  72. nazwiskoOK = false;
  73. break;
  74. }
  75. }
  76. }
  77. else
  78. nazwiskoOK = false;
  79.  
  80. //data
  81.  
  82. rok_int= stoi(rok);
  83. miesiac_int = stoi(miesiac);
  84. dzien_int = stoi(dzien);
  85.  
  86. if((rok_int>=1900)and(rok_int<=2000))
  87. if((miesiac_int>=1)and(miesiac_int<=12))
  88. if((dzien_int>=1)and(dzien_int<=31))
  89. dataOK = true;
  90. else
  91. dataOK=false;
  92.  
  93. if (imieOK==true)
  94. if(nazwiskoOK==true)
  95. if(dataOK==true)
  96. cout << 3 << endl;
  97. else
  98. cout << 2 << endl;
  99. else
  100. cout << 1 << endl;
  101. else
  102. cout << 0 << endl ;
  103.  
  104. }
  105.  
  106. return 0;
  107. }
  108.  
Success #stdin #stdout 0s 4732KB
stdin
Standard input is empty
stdout
Standard output is empty