Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <math.h>
- using namespace std;
- void text(int line)
- {
- if (line == 1)
- {
- printf("%21s", "January");
- printf("%23s", "February");
- printf("%23s", "March");
- cout << endl;
- return;
- }
- if (line == 2)
- {
- printf("%21s", "April");
- printf("%23s", "May");
- printf("%23s", "June");
- cout << endl;
- return;
- }
- if (line == 3)
- {
- printf("%21s", "Jule");
- printf("%23s", "August");
- printf("%23s", "September");
- cout << endl;
- return;
- }
- printf("%21s", "October");
- printf("%23s", "November");
- printf("%23s", "December");
- cout << endl;
- }
- bool LY(int year)
- {
- return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
- }
- int AoD(int year)
- {
- return 365 + LY(year);
- }
- int AoDM(int year, int month)
- {
- if ((month >= 1 && month <= 7 && month % 2 == 1)
- || (month >= 8 && month % 2 == 0 && month <= 12))
- return 31;
- if (month == 2)
- {
- if (LY(year))
- return 29;
- return 28;
- }
- return 30;
- }
- int AoDANY(int year, int month, int day)
- {
- int AoDANY = day;
- for(int i = 1; i < month; i++)
- {
- AoDANY += AoDM(year, i);
- }
- return AoDANY;
- }
- int AoDABOE(int day, int month, int year)
- {
- int AoDABOE = AoDANY(year, month, day);
- int i = 1;
- for(int i = 1; i < year; i++)
- {
- AoDABOE += AoD(i);
- }
- return AoDABOE;
- }
- int AoDB2D(int year1, int month1, int day1, int year2, int month2, int day2)
- {
- int AoDABOEBD1 = AoDABOE(year1, month1, day1);
- int AoDABOEBD2 = AoDABOE(year2, month2, day2);
- return (AoDABOEBD2 - AoDABOEBD1);
- }
- int DoW(int year1, int month1, int day1, int WD, int year2, int month2, int day2)
- {
- int q;
- q = AoDB2D(year1, month1, day1, year2, month2, day2);
- return (q % 7 + WD) % 7 + 7 * ((q % 7 + WD) % 7 == 0);
- }
- int main()
- {
- int year;
- int line;
- cin >> year;
- for(int line = 1; line <= 4; line++)
- {
- text(line);
- }
- int month;
- int a = 1;
- int b = 1;
- for(int week = 1; week <= 6; week++)
- {
- if (week == 1)
- {
- for (month = (line - 1)*3; month <= 3 * line; month++)
- {
- int FMD = DoW(17, 1, 2017, 2, 1, month, year);
- for (a = 1, b = 1; a <= 7 && b <= 7; a++, b++)
- {
- while (b < FMD)
- {
- printf("%3s", " ");
- b++;
- }
- printf("%3i", a);
- }
- cout << " ";
- }
- cout << endl;
- }
- else
- {
- while (month <= line * 3)
- {
- month = 3 * line - 2;
- int c = week * 7 - DoW(17, 1, 2017, 2, 1, month, year) + 2;
- int d = 0;
- for (int d = 0; d < 7 && c + d <= AoDM(month, year); d++)
- {
- printf("%3i", c + d);
- }
- while (c + d >= AoDM(month, year) && d < 7)
- {
- printf("%3s", " ");
- d += 1;
- }
- cout << " ";
- }
- cout << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement