Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- enum { jan=1, feb, mar, apr, may, jun, jul, aug, sep, octb, nov, decm };
- int main() {
- char date[8];
- int month, day, max;
- cout<<"Enter date:"<<endl;
- cin>>date;
- month = atoi(strtok(date, "."));
- day = atoi(strtok(NULL, "."));
- switch(month) {
- case feb:
- max = 29;
- break;
- case apr: case jun: case sep: case nov:
- max = 30;
- break;
- case jan: case mar: case may: case jul: case aug: case octb: case decm:
- max = 31;
- break;
- default:
- cout<<"Wrong date\n";
- exit(0);
- }
- if(day < 1 || max < day)
- cout<<"Wrong date\n";
- else
- cout<<"OK\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment