-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathES.cpp
More file actions
52 lines (52 loc) · 1.12 KB
/
ES.cpp
File metadata and controls
52 lines (52 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
using namespace std;
string months(string month)
{
if(month =="January")
return "1";
else if(month == "February")
return "2";
if(month == "March")
return "3";
else if(month == "April")
return "4";
if(month == "May")
return "5";
else if(month == "June")
return "6";
if(month == "July")
return "7";
else if(month == "August")
return "8";
if(month == "September")
return "9";
else if(month == "October")
return "10";
if(month == "November")
return "11";
else if(month == "December")
return "12";
else return "";
}
int main() {
string us = "";
getline(cin,us);
if(isalpha(us[0]))
{
int space = us.find(" ")+1;
int comma =us.find(", ")+1;
string month = us.substr(0,space-1);
string day = us.substr(space,comma-space-1);
string year = us.substr(comma+1);
cout<<day<<"/"<<months(month)<<"/"<<year;
}else
{
int slash1 = us.find("/");
int slash2 = us.rfind("/");
string month = us.substr(0,slash1);
string day = us.substr(slash1+1,slash2-slash1-1);
string year = us.substr(slash2+1);
cout<<day+"/"+month+"/"+year;
}
return 0;
}