Hello.
Solved the problem and came across such an incomprehensible moment.
The condition of the problem is as follows: Write a program, according to the number of the student group, which determines the year of graduation. The group number is entered in the format A0209 - always one letter (Latin), then 4 digits (group number and year of receipt). Year must be printed in full; Consider working with groups that arrived in the 20th and 21st centuries.
Further, the problem was solved by me in this way:
int main() { time_t t; time(&t); int year=localtime(&t)->tm_year-100; int x; string god,grup,god1,god2; cout<<"Vvedite nazvanie gruppi: "; cin>>grup; god1 = grup[3] ; god2 = grup[4]; god = god1+god2; x = atoi(god.c_str()); if (x>year) { cout<<19<<x+6; } else { cout<<20<<x+6; } }
Everything works correctly, with the exception of the years 00, 01, 02, 03. When I enter these years, I’ll print out the graduation date with a three-digit number, that is, I enter 00, I get 206, and if I enter the year not from the above, everything is fine. For example, 07-2013, 75- 1981. And so on. So what is wrong here? )