Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int min(int a, int b)
  9. {
  10.     return a < b ? a : b;
  11. }
  12.  
  13. int perimeter(int x0, int y0, int x1, int y1, int x2, int y2)
  14. {
  15.     int first_side = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2));
  16.     int second_side = sqrt(pow(x2 - x0, 2) + pow(y2 - y0, 2));
  17.     int thirst_side = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
  18.  
  19.     return first_side + second_side + thirst_side;
  20. }
  21.  
  22. bool is_power_five(int a)
  23. {
  24.     bool res = false;
  25.     while(a % 5 == 0)
  26.     {
  27.         if (a == 5) { res = true; break; };
  28.         a /= 5;
  29.     }
  30.     return res;
  31. }
  32.  
  33. int task_3(vector <int> a)
  34. {
  35.     int cnt = 0;
  36.     for (int i = 0; i < a.size(); i++)
  37.     {
  38.         cnt += is_power_five(a[i]) ? 1 : 0;
  39.     }
  40.     return cnt;
  41. }
  42.  
  43. bool polindrom(string a)
  44. {
  45.     string tmp = a;
  46.     reverse(a.begin(), a.end());
  47.     return a == tmp ? true : false;
  48. }
  49.  
  50. int gcd(int a, int b)
  51. {
  52.     return !b ? abs(a) : gcd(b, a % b);
  53. }
  54.  
  55. int sum(int a)
  56. {
  57.     if (a / 10 > 0) {return a % 10 + sum(a / 10);}
  58.     else {return a;}
  59. }
  60.  
  61. int digital_sqrt(int a)
  62. {
  63.     if (a / 10 > 0) {return digital_sqrt(sum(a));}
  64.     else {return a;}
  65. }
  66.  
  67. int main()
  68. {
  69.  
  70.     //cout << digital_sqrt(625) << endl;
  71.  
  72.     //cout << gcd (6, 7) << endl;
  73.  
  74.     //cout << sum(125) << endl;
  75.  
  76.     // string a = "02020";
  77.  
  78.     // cout << polindrom(a) << endl;
  79.  
  80.     ////////////////////-task_3-///////////////
  81.  
  82.     // int buffer;
  83.     // vector <int> seq;
  84.  
  85.     // do
  86.     // {
  87.     //     cin >> buffer;
  88.     //     if (buffer == 0) break;
  89.     //     seq.push_back(buffer);
  90.     // } while (buffer != 0);
  91.  
  92.     // cout << task_3(seq) << endl;
  93.  
  94.     ////////////////////-task_3-///////////////
  95.  
  96.     // int a, b;
  97.  
  98.     // cin >> a >> b;
  99.  
  100.     // cout << 'minimal number is ' << min(a, b) << endl;
  101.  
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement