Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #pragma once
  2. #include "pch.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6. int sum(int a)
  7. {
  8. int s = 0;
  9. while (a)
  10. {
  11. s = s + a % 10;
  12. a = a / 10;
  13. }
  14. return s;
  15. }
  16.  
  17. //Передача указателя
  18. void sum(int a, int *s)
  19. {
  20. *s = 0;
  21. while (a)
  22. {
  23. *s = *s + a % 10;
  24. a /= 10;
  25. }
  26. }
  27.  
  28. int fdig_ldig(int a)
  29. {
  30. int b = a % 10;
  31. while (a > 9)
  32. {
  33. a /= 10;
  34. }
  35. return (a == b) ? 1 : 0;
  36. }
  37.  
  38. int count_del(int a)
  39. {
  40. int k = 2;
  41. for (int d = 2; d <= a / 2;d++)
  42. {
  43. if (a%d == 0) k++;
  44. }
  45. return k;
  46. }
  47.  
  48. int prime(int a)
  49. {
  50. if (a <= 1) return 0;
  51. int d = 2;
  52. while (d*d <= a)
  53. {
  54. if (a%d == 0) return 0;
  55. d++;
  56. }
  57. return 1;
  58. }
  59.  
  60. int progr(int a)
  61. {
  62. if (a <= 100) return 0;
  63. int y = a % 10, z = a / 10 % 10;
  64. a /= 10;
  65. int d = y - z;
  66. while (a)
  67. {
  68. if (y - z != d) return 0;
  69. y = z; a /= 10; z = a % 10;
  70. }
  71. return 1;
  72. }
  73.  
  74. double gorner(int n, double x)
  75. {
  76. double a, s = 0;
  77. cout << "Введите " << n + 1 << " коэффициентов многочлена: " << endl;
  78. for (int i = n; i >= 0; i--)
  79. {
  80. cin >> a;
  81. s = s * x + a;
  82. }
  83. return s;
  84. }
  85.  
  86. int palindrom4ik(int a)
  87. {
  88. int s = 0, copya = a;
  89. while (a)
  90. {
  91. s = s * 10 + a % 10;
  92. a = a / 10;
  93. }
  94. return (s == copya) ? 1 : 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement