Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < SFML / Graphics.hpp >
- #include < iostream >
- #include < vector >
- #include < cmath >
- #include < string >
- using namespace std;
- using namespace sf; //включаем пространство имен sf, чтобы постоянно не писать sf::
- bool whatyear(int n) {
- if (n % 400 == 0 || (n % 4 == 0 && n % 100 != 0)) {
- return 1;
- } else {
- return 0;
- }
- }
- int howmanyday(int n) {
- if (whatyear(n) == 1) {
- return 366;
- } else {
- return 365;
- }
- }
- int kol(int m, int y) {
- if (m == 1) {
- return 31;
- }
- if (m == 2) {
- if (howmanyday(y) == 365) {
- return 28;
- } else {
- return 29;
- }
- }
- if (m == 3) {
- return 31;
- }
- if (m == 4) {
- return 30;
- }
- if (m == 5) {
- return 31;
- }
- if (m == 6) {
- return 30;
- }
- if (m == 7) {
- return 31;
- }
- if (m == 8) {
- return 31;
- }
- if (m == 9) {
- return 30;
- }
- if (m == 10) {
- return 31;
- }
- if (m == 11) {
- return 30;
- }
- if (m == 12) {
- return 31;
- }
- }
- int kolday(int d, int m, int y) {
- int ans = 0;
- for (int i = 1; i < m; ++i) {
- ans += kol(i, y);
- }
- ans += (d - 1);
- return ans;
- }
- int koldayall(int d, int m, int y) {
- int ans = 0;
- ans += kolday(d, m, y);
- for (int i = 1; i < y; i++) {
- ans += howmanyday(i);
- }
- return ans;
- }
- int daybetween(int d2, int m2, int y2) {
- return abs(koldayall(28, 1, 2019) - koldayall(d2, m2, y2));
- }
- int week(int d, int m, int y) {
- if (y < 2019 || (y == 2019 && m < 1) || (y == 2019 && m == 1 && d < 28)) {
- return 7 - (daybetween(d, m, y) - 1) % 7;
- }
- if (d == 28 && m == 1 && y == 2019) {
- return 1;
- }
- return 1 + (daybetween(d, m, y)) % 7;
- }
- string chatt(int a) {
- string s;
- if (a < 10) {
- s.push_back(a + '0');
- } else {
- s.push_back(a / 10 + '0');
- s.push_back(a % 10 + '0');
- }
- return s;
- }
- int yar(string s) {
- int o = 0;
- for (int i = 0; i < s.size(); i++) {
- o += (s[i] - '0') * pow(10, s.size() - i - 1);
- }
- return o;
- }
- int main() {
- vector < string > a(13);
- a[0] = "Mon Tue Wed Thu Fri Sar Sun";
- a[1] = "January";
- a[2] = "February";
- a[3] = "March";
- a[4] = "April";
- a[5] = "May";
- a[6] = "June";
- a[7] = "July";
- a[8] = "August";
- a[9] = "September";
- a[10] = "October";
- a[11] = "November";
- a[12] = "December";
- string year;
- cin» year;
- int n = yar(year);
- RenderWindow window(sf::VideoMode(1300, 800), "Lesson 3. kychka-pc.ru"); //увеличили для удобства размер окна
- Font font;
- font.loadFromFile("CyrilicOld.ttf");
- Text text("", font, 20);
- text.setColor(Color::Black);
- text.setStyle(sf::Text::Bold | sf::Text::Underlined);
- Image heroimage; //создаем объект Image (изображение)
- heroimage.loadFromFile("nastol.com.ua-50310 (1).jpg"); //загружаем в него файл
- Texture herotexture; //создаем объект Texture (текстура)
- herotexture.loadFromImage(heroimage); //передаем в него объект Image (изображения)
- Sprite herosprite; //создаем объект Sprite(спрайт)
- herosprite.setTexture(herotexture); //передаём в него объект Texture (текстуры)
- herosprite.setPosition(0, 0); //задаем начальные координаты появления спрайта
- while (window.isOpen()) {
- sf::Event event;
- while (window.pollEvent(event)) {
- if (event.type == sf::Event::Closed)
- window.close();
- }
- window.clear();
- window.draw(herosprite); //выводим спрайт на экран
- text.setString(a[1]);
- text.setPosition(160, 0);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(50, 20);
- window.draw(text);
- int v = week(1, 1, n);
- int strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
- int stry = 40;
- for (int i = 1; i <= kol(1, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 1, n) == 7) {
- stry += 20;
- strx = 10 + 60;
- } else {
- strx += 48;
- }
- }
- text.setString(a[2]);
- text.setPosition(610, 0);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(500, 20);
- window.draw(text);
- v = week(1, 2, n);
- strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 40;
- for (int i = 1; i <= kol(2, n); ++i)
- kychka - pc | SFML | Уроки по sfml, форум, ..
- kychka - pc.ru
- {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 2, n) == 7) {
- stry += 20;
- strx = 10 + 510;
- } else {
- strx += 48;
- }
- }
- text.setString(a[3]);
- text.setPosition(1060, 0);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(950, 20);
- window.draw(text);
- v = week(1, 3, n);
- strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 40;
- for (int i = 1; i <= kol(3, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 3, n) == 7) {
- stry += 20;
- strx = 10 + 960;
- } else {
- strx += 48;
- }
- }
- text.setString(a[4]);
- text.setPosition(160, 200);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(50, 220);
- window.draw(text);
- v = week(1, 4, n);
- strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 220 + 20;
- for (int i = 1; i <= kol(4, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 4, n) == 7) {
- stry += 20;
- strx = 10 + 60;
- } else {
- strx += 48;
- }
- }
- text.setString(a[5]);
- text.setPosition(610, 200);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(500, 220);
- window.draw(text);
- v = week(1, 5, n);
- strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 220 + 20;
- for (int i = 1; i <= kol(5, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 5, n) == 7) {
- stry += 20;
- strx = 10 + 510;
- } else {
- strx += 48;
- }
- }
- text.setString(a[6]);
- text.setPosition(1060, 200);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(950, 220);
- window.draw(text);
- v = week(1, 6, n);
- strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 220 + 20;
- for (int i = 1; i <= kol(6, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 6, n) == 7) {
- stry += 20;
- strx = 10 + 960;
- } else {
- strx += 48;
- }
- }
- text.setString(a[7]);
- text.setPosition(160, 400);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(50, 420);
- window.draw(text);
- v = week(1, 7, n);
- strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 420 + 20;
- for (int i = 1; i <= kol(7, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 7, n) == 7) {
- stry += 20;
- strx = 10 + 60;
- } else {
- strx += 48;
- }
- }
- text.setString(a[8]);
- text.setPosition(610, 400);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(500, 420);
- window.draw(text);
- v = week(1, 8, n);
- strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 420 + 20;
- for (int i = 1; i <= kol(8, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 8, n) == 7) {
- stry += 20;
- strx = 10 + 510;
- } else {
- strx += 48;
- }
- }
- window.draw(text);
- text.setString(a[9]);
- text.setPosition(1060, 400);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(950, 420);
- window.draw(text);
- v = week(1, 9, n);
- strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 420 + 20;
- for (int i = 1; i <= kol(9, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 9, n) == 7) {
- stry += 20;
- strx = 10 + 960;
- } else {
- strx += 48;
- }
- }
- text.setString(a[10]);
- text.setPosition(160, 600);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(50, 620);
- window.draw(text);
- v = week(1, 10, n);
- strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 620 + 20;
- for (int i = 1; i <= kol(10, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx,
- stry);
- window.draw(text);
- if (week(i, 10, n) == 7) {
- stry += 20;
- strx = 10 + 60;
- } else {
- strx += 48;
- }
- }
- text.setString(a[11]);
- text.setPosition(610, 600);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(500, 620);
- window.draw(text);
- v = week(1, 11, n);
- strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 620 + 20;
- for (int i = 1; i <= kol(11, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 11, n) == 7) {
- stry += 20;
- strx = 10 + 510;
- } else {
- strx += 48;
- }
- }
- text.setString(a[12]);
- text.setPosition(1060, 600);
- window.draw(text);
- text.setString(a[0]);
- text.setPosition(950, 620);
- window.draw(text);
- v = week(1, 12, n);
- strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
- stry = 620 + 20;
- for (int i = 1; i <= kol(12, n); ++i) {
- text.setString(chatt(i));
- text.setPosition(strx, stry);
- window.draw(text);
- if (week(i, 12, n) == 7) {
- stry += 20;
- strx = 10 + 960;
- } else {
- strx += 48;
- }
- }
- window.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement