获取前3个字符,存到字符数组Moons里面,后两个数字当成int直接存到Day里面,最后直接输出。
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
char Moons[3];
for (int i = 0; i < 3; i++) {
cin >> Moons[i];
}
int Day;
cin >> Day;
string A = Moons;
if (A == "Jan") {
printf("%d", 1);
} else if (A == "Feb") {
printf("%d", 2);
} else if (A == "Mar") {
printf("%d", 3);
} else if (A == "Apr") {
printf("%d", 4);
} else if (A == "May") {
printf("%d", 5);
} else if (A == "Jun") {
printf("%d", 6);
} else if (A == "Jul") {
printf("%d", 7);
} else if (A == "Aug") {
printf("%d", 8);
} else if (A == "Sep") {
printf("%d", 9);
} else if (A == "Oct") {
printf("%d", 10);
} else if (A == "Nov") {
printf("%d", 11);
} else if (A == "Dec") {
printf("%d", 12);
}
cout << " " << Day;
return 0;
}