Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. //1
  6. /*int lenght = 0;
  7. std::cout << "Enter N:";
  8. std::cin >> lenght;
  9. int *array = new int[lenght];
  10. std::cout << "Enter array:" << std::endl;
  11. unsigned int sum=0;
  12. for (int i = 0; i < lenght; i++)
  13. {
  14. std::cin >> array[i];
  15. sum += array[i];
  16. }
  17. sum = (0 + lenght) / 2 * (lenght+1) - sum;
  18. std::cout << "Missing element:" << sum;*/
  19. //2
  20. /*int lenght = 0;
  21. std::cout << "Enter N:";
  22. std::cin >> lenght;
  23. int *array = new int[lenght];
  24. std::cout << "Enter array:" << std::endl;
  25. for (int i = 0; i < lenght; i++)
  26. {
  27. std::cin >> array[i];
  28. }
  29. int count=0;
  30. for (int i = 0; i < lenght; i++)
  31. if (array[i] != 0)
  32. {
  33. int m = array[i];
  34. count++;
  35. for (int j = 0; j < lenght; j++)
  36. if (m == array[j])
  37. array[j] = 0;
  38. };
  39. std::cout <<"Diffirent value:"<< count;*/
  40. //3
  41. /*const int lenght = 8;
  42. int array[lenght]{ };
  43. int m;
  44. std::cout << "Enter m:";
  45. std::cin >> m;
  46. int i = 0;
  47. int count = 0;
  48. int k= 1;
  49. while (count != lenght-1)
  50. {
  51. if (k % m == 0)
  52. {
  53. count++;
  54. array[i] = 1;
  55. k = 0;
  56. }
  57. if (i >= lenght-1)
  58. i =i-lenght;
  59. while (array[i + 1] == 1)
  60. {
  61. if (i >= lenght - 1)
  62. i = i - lenght;
  63. i++;
  64. if (i >= lenght - 1)
  65. i = i - lenght;
  66. };
  67. i++;
  68. k++;
  69. }
  70. for (int j = 0; j < lenght; j++)
  71. if (array[j] != 1)
  72. std::cout << "Live:" << j;*/
  73. std::cout << std::endl;
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement