fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int n ; cin>>n;
  8. cin.ignore();
  9. vector<string>arr(n);
  10. for(int i = 0 ; i<n;i++){
  11. getline(cin,arr[i]);
  12. }
  13. for(string s : arr) {
  14. if(isalpha(s[1])) s = "0"+s;
  15. string y = s.substr(9,4);
  16. string month = s.substr(5,3);
  17. string m ;
  18. if (month == "Jan") m = "01";
  19. else if (month == "Feb") m = "02";
  20. else if (month == "Mar") m = "03";
  21. else if (month == "Apr") m = "04";
  22. else if (month == "May") m = "05";
  23. else if (month == "Jun") m = "06";
  24. else if (month == "Jul") m = "07";
  25. else if (month == "Aug") m = "08";
  26. else if (month == "Sep") m = "09";
  27. else if (month == "Oct") m = "10";
  28. else if (month == "Nov") m = "11";
  29. else if (month == "Dec") m = "12";
  30. string d = s.substr(0,2);
  31. string date = y+"-"+m+"-"+d;
  32. cout<<date<<endl;
  33.  
  34. }
  35.  
  36. // your code goes here
  37. return 0;
  38. }
Success #stdin #stdout 0s 5324KB
stdin
2
22th Oct 2035
14th Sep 2029
stdout
2035-10-22
2029-09-14