fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool nhuan(int y)
  5. {
  6. return(y % 4 == 0 && y % 100 != 0) ||(y % 400 == 0);
  7. }
  8.  
  9. int songay(int t, int n)
  10. {
  11. if(t== 1 || t==3 || t ==5 || t==7 || t==8 || t==10 || t==12)
  12. return 31;
  13. if(t==4 || t==6 || t== 9 || t==11) return 30;
  14. if(nhuan(n)) return 29;
  15. else return 28;
  16. }
  17.  
  18. string s, no= "KHONG TAO DUOC";
  19.  
  20. int main()
  21. {
  22. freopen("bai01.inp","r",stdin);
  23. freopen("bai01.out","w",stdout);
  24. cin >> s;
  25. if(s[0]=='0') s.erase(0,1);
  26. if(s[0]=='0') s.erase(0,1);
  27. int ng, th, na;
  28. if(s.length()<4) cout<<no;
  29. else if(s.length()==4)
  30. cout<<s[0]<<'/'<<s[1]<<'/'<<s[2]<<s[3];
  31. else if(s[1]=='1' && s[2] <= '2')
  32. cout<<s[0]<<'/'<<s[1]<<s[2]<<'/'<<s[3]<<s[4];
  33. else
  34. {
  35. ng =(s[0]-48)*10 + s[1]-48;
  36. th = s[2] - 48;
  37. na =(s[3]-48)*10 + s[4]-48;
  38. if (na==0) na=100;
  39. if (ng > songay(th, 2000+na))
  40. cout << no;
  41. else
  42. cout << ng << '/'<<th<<'/' << na;
  43. }
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty