Advertisement
berinkaq

roma

Feb 11th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. #include < SFML / Graphics.hpp >
  2. #include < iostream >
  3. #include < vector >
  4. #include < cmath >
  5. #include < string >
  6. using namespace std;
  7. using namespace sf; //включаем пространство имен sf, чтобы постоянно не писать sf::
  8. bool whatyear(int n) {
  9. if (n % 400 == 0 || (n % 4 == 0 && n % 100 != 0)) {
  10. return 1;
  11. } else {
  12. return 0;
  13. }
  14. }
  15. int howmanyday(int n) {
  16. if (whatyear(n) == 1) {
  17. return 366;
  18. } else {
  19. return 365;
  20. }
  21. }
  22. int kol(int m, int y) {
  23. if (m == 1) {
  24. return 31;
  25. }
  26. if (m == 2) {
  27. if (howmanyday(y) == 365) {
  28. return 28;
  29. } else {
  30. return 29;
  31. }
  32. }
  33. if (m == 3) {
  34. return 31;
  35. }
  36. if (m == 4) {
  37. return 30;
  38. }
  39. if (m == 5) {
  40. return 31;
  41. }
  42. if (m == 6) {
  43. return 30;
  44. }
  45. if (m == 7) {
  46. return 31;
  47. }
  48. if (m == 8) {
  49. return 31;
  50. }
  51. if (m == 9) {
  52. return 30;
  53. }
  54. if (m == 10) {
  55. return 31;
  56. }
  57. if (m == 11) {
  58. return 30;
  59. }
  60. if (m == 12) {
  61. return 31;
  62. }
  63. }
  64. int kolday(int d, int m, int y) {
  65. int ans = 0;
  66. for (int i = 1; i < m; ++i) {
  67. ans += kol(i, y);
  68. }
  69. ans += (d - 1);
  70. return ans;
  71. }
  72. int koldayall(int d, int m, int y) {
  73. int ans = 0;
  74. ans += kolday(d, m, y);
  75. for (int i = 1; i < y; i++) {
  76. ans += howmanyday(i);
  77. }
  78. return ans;
  79. }
  80. int daybetween(int d2, int m2, int y2) {
  81. return abs(koldayall(28, 1, 2019) - koldayall(d2, m2, y2));
  82. }
  83. int week(int d, int m, int y) {
  84. if (y < 2019 || (y == 2019 && m < 1) || (y == 2019 && m == 1 && d < 28)) {
  85. return 7 - (daybetween(d, m, y) - 1) % 7;
  86. }
  87. if (d == 28 && m == 1 && y == 2019) {
  88. return 1;
  89. }
  90. return 1 + (daybetween(d, m, y)) % 7;
  91.  
  92. }
  93. string chatt(int a) {
  94. string s;
  95. if (a < 10) {
  96. s.push_back(a + '0');
  97. } else {
  98. s.push_back(a / 10 + '0');
  99. s.push_back(a % 10 + '0');
  100. }
  101. return s;
  102. }
  103. int yar(string s) {
  104. int o = 0;
  105. for (int i = 0; i < s.size(); i++) {
  106. o += (s[i] - '0') * pow(10, s.size() - i - 1);
  107. }
  108. return o;
  109. }
  110. int main() {
  111. vector < string > a(13);
  112. a[0] = "Mon Tue Wed Thu Fri Sar Sun";
  113. a[1] = "January";
  114. a[2] = "February";
  115. a[3] = "March";
  116. a[4] = "April";
  117. a[5] = "May";
  118. a[6] = "June";
  119. a[7] = "July";
  120. a[8] = "August";
  121. a[9] = "September";
  122. a[10] = "October";
  123. a[11] = "November";
  124. a[12] = "December";
  125. string year;
  126. cin» year;
  127. int n = yar(year);
  128. RenderWindow window(sf::VideoMode(1300, 800), "Lesson 3. kychka-pc.ru"); //увеличили для удобства размер окна
  129. Font font;
  130. font.loadFromFile("CyrilicOld.ttf");
  131. Text text("", font, 20);
  132. text.setColor(Color::Black);
  133. text.setStyle(sf::Text::Bold | sf::Text::Underlined);
  134. Image heroimage; //создаем объект Image (изображение)
  135. heroimage.loadFromFile("nastol.com.ua-50310 (1).jpg"); //загружаем в него файл
  136. Texture herotexture; //создаем объект Texture (текстура)
  137. herotexture.loadFromImage(heroimage); //передаем в него объект Image (изображения)
  138. Sprite herosprite; //создаем объект Sprite(спрайт)
  139. herosprite.setTexture(herotexture); //передаём в него объект Texture (текстуры)
  140. herosprite.setPosition(0, 0); //задаем начальные координаты появления спрайта
  141.  
  142. while (window.isOpen()) {
  143. sf::Event event;
  144. while (window.pollEvent(event)) {
  145. if (event.type == sf::Event::Closed)
  146. window.close();
  147. }
  148. window.clear();
  149. window.draw(herosprite); //выводим спрайт на экран
  150. text.setString(a[1]);
  151. text.setPosition(160, 0);
  152. window.draw(text);
  153. text.setString(a[0]);
  154. text.setPosition(50, 20);
  155. window.draw(text);
  156. int v = week(1, 1, n);
  157. int strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
  158. int stry = 40;
  159. for (int i = 1; i <= kol(1, n); ++i) {
  160. text.setString(chatt(i));
  161. text.setPosition(strx, stry);
  162. window.draw(text);
  163. if (week(i, 1, n) == 7) {
  164. stry += 20;
  165. strx = 10 + 60;
  166. } else {
  167. strx += 48;
  168. }
  169. }
  170. text.setString(a[2]);
  171. text.setPosition(610, 0);
  172. window.draw(text);
  173. text.setString(a[0]);
  174. text.setPosition(500, 20);
  175. window.draw(text);
  176. v = week(1, 2, n);
  177. strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
  178. stry = 40;
  179. for (int i = 1; i <= kol(2, n); ++i)
  180. kychka - pc | SFML | Уроки по sfml, форум, ..
  181. kychka - pc.ru
  182.  
  183. {
  184. text.setString(chatt(i));
  185. text.setPosition(strx, stry);
  186. window.draw(text);
  187. if (week(i, 2, n) == 7) {
  188. stry += 20;
  189. strx = 10 + 510;
  190. } else {
  191. strx += 48;
  192. }
  193. }
  194.  
  195. text.setString(a[3]);
  196. text.setPosition(1060, 0);
  197. window.draw(text);
  198. text.setString(a[0]);
  199. text.setPosition(950, 20);
  200. window.draw(text);
  201. v = week(1, 3, n);
  202. strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
  203. stry = 40;
  204. for (int i = 1; i <= kol(3, n); ++i) {
  205. text.setString(chatt(i));
  206. text.setPosition(strx, stry);
  207. window.draw(text);
  208. if (week(i, 3, n) == 7) {
  209. stry += 20;
  210. strx = 10 + 960;
  211. } else {
  212. strx += 48;
  213. }
  214. }
  215.  
  216. text.setString(a[4]);
  217. text.setPosition(160, 200);
  218. window.draw(text);
  219. text.setString(a[0]);
  220. text.setPosition(50, 220);
  221. window.draw(text);
  222.  
  223. v = week(1, 4, n);
  224. strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
  225. stry = 220 + 20;
  226. for (int i = 1; i <= kol(4, n); ++i) {
  227. text.setString(chatt(i));
  228. text.setPosition(strx, stry);
  229. window.draw(text);
  230. if (week(i, 4, n) == 7) {
  231. stry += 20;
  232. strx = 10 + 60;
  233. } else {
  234. strx += 48;
  235. }
  236. }
  237.  
  238. text.setString(a[5]);
  239. text.setPosition(610, 200);
  240. window.draw(text);
  241. text.setString(a[0]);
  242. text.setPosition(500, 220);
  243. window.draw(text);
  244.  
  245. v = week(1, 5, n);
  246. strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
  247. stry = 220 + 20;
  248. for (int i = 1; i <= kol(5, n); ++i) {
  249. text.setString(chatt(i));
  250. text.setPosition(strx, stry);
  251. window.draw(text);
  252. if (week(i, 5, n) == 7) {
  253. stry += 20;
  254. strx = 10 + 510;
  255. } else {
  256. strx += 48;
  257. }
  258. }
  259.  
  260. text.setString(a[6]);
  261. text.setPosition(1060, 200);
  262. window.draw(text);
  263. text.setString(a[0]);
  264. text.setPosition(950, 220);
  265. window.draw(text);
  266. v = week(1, 6, n);
  267. strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
  268. stry = 220 + 20;
  269. for (int i = 1; i <= kol(6, n); ++i) {
  270. text.setString(chatt(i));
  271. text.setPosition(strx, stry);
  272. window.draw(text);
  273. if (week(i, 6, n) == 7) {
  274. stry += 20;
  275. strx = 10 + 960;
  276. } else {
  277. strx += 48;
  278. }
  279. }
  280.  
  281. text.setString(a[7]);
  282. text.setPosition(160, 400);
  283. window.draw(text);
  284. text.setString(a[0]);
  285. text.setPosition(50, 420);
  286. window.draw(text);
  287. v = week(1, 7, n);
  288. strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
  289. stry = 420 + 20;
  290. for (int i = 1; i <= kol(7, n); ++i) {
  291. text.setString(chatt(i));
  292. text.setPosition(strx, stry);
  293. window.draw(text);
  294. if (week(i, 7, n) == 7) {
  295. stry += 20;
  296. strx = 10 + 60;
  297. } else {
  298. strx += 48;
  299. }
  300. }
  301.  
  302. text.setString(a[8]);
  303. text.setPosition(610, 400);
  304. window.draw(text);
  305. text.setString(a[0]);
  306. text.setPosition(500, 420);
  307. window.draw(text);
  308. v = week(1, 8, n);
  309. strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
  310. stry = 420 + 20;
  311. for (int i = 1; i <= kol(8, n); ++i) {
  312. text.setString(chatt(i));
  313. text.setPosition(strx, stry);
  314. window.draw(text);
  315. if (week(i, 8, n) == 7) {
  316. stry += 20;
  317. strx = 10 + 510;
  318. } else {
  319. strx += 48;
  320. }
  321. }
  322.  
  323. window.draw(text);
  324. text.setString(a[9]);
  325. text.setPosition(1060, 400);
  326. window.draw(text);
  327. text.setString(a[0]);
  328. text.setPosition(950, 420);
  329. window.draw(text);
  330. v = week(1, 9, n);
  331. strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
  332. stry = 420 + 20;
  333. for (int i = 1; i <= kol(9, n); ++i) {
  334. text.setString(chatt(i));
  335. text.setPosition(strx, stry);
  336. window.draw(text);
  337. if (week(i, 9, n) == 7) {
  338. stry += 20;
  339. strx = 10 + 960;
  340. } else {
  341. strx += 48;
  342. }
  343. }
  344.  
  345. text.setString(a[10]);
  346. text.setPosition(160, 600);
  347. window.draw(text);
  348. text.setString(a[0]);
  349. text.setPosition(50, 620);
  350. window.draw(text);
  351. v = week(1, 10, n);
  352. strx = 60 + 10 + (v - 1) * 20 + (v - 1) * 30;
  353. stry = 620 + 20;
  354. for (int i = 1; i <= kol(10, n); ++i) {
  355. text.setString(chatt(i));
  356. text.setPosition(strx,
  357.  
  358. stry);
  359. window.draw(text);
  360. if (week(i, 10, n) == 7) {
  361. stry += 20;
  362. strx = 10 + 60;
  363. } else {
  364. strx += 48;
  365. }
  366. }
  367.  
  368. text.setString(a[11]);
  369. text.setPosition(610, 600);
  370. window.draw(text);
  371. text.setString(a[0]);
  372. text.setPosition(500, 620);
  373. window.draw(text);
  374. v = week(1, 11, n);
  375. strx = 510 + 10 + (v - 1) * 20 + (v - 1) * 30;
  376. stry = 620 + 20;
  377. for (int i = 1; i <= kol(11, n); ++i) {
  378. text.setString(chatt(i));
  379. text.setPosition(strx, stry);
  380. window.draw(text);
  381. if (week(i, 11, n) == 7) {
  382. stry += 20;
  383. strx = 10 + 510;
  384. } else {
  385. strx += 48;
  386. }
  387. }
  388.  
  389. text.setString(a[12]);
  390. text.setPosition(1060, 600);
  391. window.draw(text);
  392. text.setString(a[0]);
  393. text.setPosition(950, 620);
  394. window.draw(text);
  395. v = week(1, 12, n);
  396. strx = 960 + 10 + (v - 1) * 20 + (v - 1) * 30;
  397. stry = 620 + 20;
  398. for (int i = 1; i <= kol(12, n); ++i) {
  399. text.setString(chatt(i));
  400. text.setPosition(strx, stry);
  401. window.draw(text);
  402. if (week(i, 12, n) == 7) {
  403. stry += 20;
  404. strx = 10 + 960;
  405. } else {
  406. strx += 48;
  407. }
  408. }
  409. window.display();
  410. }
  411. return 0;
  412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement