Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <Windows.h>
  6.  
  7. void InputDate(int &N) {
  8.  
  9. while (N > 10000) {
  10. std::printf("Введите значение N (не более 10 000): ");
  11. std::cin >> N;
  12. }
  13. }
  14.  
  15. void Calcul(int N) {
  16. int z = 0;
  17. int k = 0;
  18. int k_finish = 0;
  19. int array[5];
  20. while (z < 2498) {
  21. k = z + z + 1 + z + 2 + z + 3;
  22. if (k == N) {
  23. array[0] = z;
  24. array[1] = z+1;
  25. array[2] = z+2;
  26. array[3] = z+3;
  27. k_finish = k;
  28. z = 2500;
  29. // std::printf("%d %d", k, k_finish);
  30. }
  31.  
  32. z++;
  33. }
  34. if (k_finish == N) {
  35. std::printf("\nДа, значения найдены: %d, %d, %d, %d", array[0], array[1], array[2], array[3]);
  36. }
  37. else {
  38. std::printf("\nНет, значения не были найдены.");
  39. }
  40. }
  41.  
  42.  
  43.  
  44. int main()
  45. {
  46.  
  47. int N = 10001;
  48. SetConsoleCP(1251);
  49. SetConsoleOutputCP(1251);
  50. InputDate(N);
  51. Calcul(N);
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement