fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. bool sprawdz(string a)
  8. {
  9. int dl=a.length();
  10. dl=dl-1;
  11. if(int(a[0])>64 && int(a[0])<91)
  12. {
  13. int x=0;
  14. for(int i=1;i<dl;i++)
  15. {
  16. if(int (a[i])>96 && int (a[i])<123) x++;
  17. else x=0;
  18. }
  19. if(x==dl-1) return true;
  20. else return false;
  21. }
  22. else return false;
  23. }
  24. bool data1(string data)
  25. {
  26. string rok,miesiac,dzien;
  27. int dl=data.length();
  28. if(data[4]!='-' || data[7]!='-') return false;
  29. else
  30. {
  31. if(dl!=10) return false;
  32. else
  33. {
  34. for(int i=0;i<4;i++)
  35. {
  36. rok[i]=data[i];
  37. }
  38. for(int i=0;i<2;i++)
  39. {
  40. miesiac[i]=data[5+i];
  41. }
  42. for(int i=0;i<2;i++)
  43. {
  44. dzien[i]=data[8+i];
  45. }
  46. int x=atoi(rok.c_str());
  47. int y=atoi(miesiac.c_str());
  48. int z=atoi(dzien.c_str());
  49. if(x<=2000 && x>=1900 && y<=12 && y>=1 && z<=31 && z>0) return true;
  50. else return false;
  51.  
  52. }
  53. }
  54.  
  55.  
  56.  
  57. }
  58.  
  59. int main()
  60. {
  61. string a,b,data,z;
  62.  
  63. while(cin>>z>>a>>z>>b>>z>>z>>data)
  64. {
  65. int dl=a.length();
  66. if(sprawdz(a) && dl<=11)
  67. {
  68. dl=b.length();
  69. if(sprawdz(b) && dl<=21)
  70. {
  71. if(data1(data)) cout<<"3\n";
  72. else cout<<"2\n";
  73. }
  74. else cout<<"1\n";
  75. }
  76. else cout<<"0\n";
  77.  
  78.  
  79. }
  80.  
  81.  
  82. system("pause");
  83. return 0;
  84. }
  85.  
Success #stdin #stdout #stderr 0s 4496KB
stdin
Imie: Z; Nazwisko: Za; Data ur.: 1900-1--30
stdout
3
stderr
sh: 1: pause: not found