fork(1) 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. if(int (miesiac[i])<47 || int (miesiac[i])>57) return false;
  42. }
  43. for(int i=0;i<2;i++)
  44. {
  45. dzien[i]=data[8+i];
  46. if(int (dzien[i])<47 || int (dzien[i])>57) return false;
  47. }
  48.  
  49. int x=atoi(rok.c_str());
  50. int y=atoi(miesiac.c_str());
  51. int z=atoi(dzien.c_str());
  52. if(x<=2000 && x>=1900 && y<=12 && y>=1 && z<=31 && z>0) return true;
  53. else return false;
  54.  
  55. }
  56. }
  57.  
  58.  
  59.  
  60. }
  61.  
  62. int main()
  63. {
  64. string a,b,data,z;
  65.  
  66. while(cin>>z>>a>>z>>b>>z>>z>>data)
  67. {
  68. int dl=a.length();
  69. if(sprawdz(a) && dl<=11)
  70. {
  71. dl=b.length();
  72. if(sprawdz(b) && dl<=21)
  73. {
  74. if(data1(data)) cout<<"3\n";
  75. else cout<<"2\n";
  76. }
  77. else cout<<"1\n";
  78. }
  79. else cout<<"0\n";
  80.  
  81.  
  82. }
  83.  
  84.  
  85. return 0;
  86. }
  87.  
Success #stdin #stdout 0s 4532KB
stdin
Standard input is empty
stdout
Standard output is empty