Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- #include <vector>
- using namespace std;
- int min(int a, int b)
- {
- return a < b ? a : b;
- }
- int perimeter(int x0, int y0, int x1, int y1, int x2, int y2)
- {
- int first_side = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2));
- int second_side = sqrt(pow(x2 - x0, 2) + pow(y2 - y0, 2));
- int thirst_side = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
- return first_side + second_side + thirst_side;
- }
- bool is_power_five(int a)
- {
- bool res = false;
- while(a % 5 == 0)
- {
- if (a == 5) { res = true; break; };
- a /= 5;
- }
- return res;
- }
- int task_3(vector <int> a)
- {
- int cnt = 0;
- for (int i = 0; i < a.size(); i++)
- {
- cnt += is_power_five(a[i]) ? 1 : 0;
- }
- return cnt;
- }
- bool polindrom(string a)
- {
- string tmp = a;
- reverse(a.begin(), a.end());
- return a == tmp ? true : false;
- }
- int gcd(int a, int b)
- {
- return !b ? abs(a) : gcd(b, a % b);
- }
- int sum(int a)
- {
- if (a / 10 > 0) {return a % 10 + sum(a / 10);}
- else {return a;}
- }
- int digital_sqrt(int a)
- {
- if (a / 10 > 0) {return digital_sqrt(sum(a));}
- else {return a;}
- }
- int main()
- {
- //cout << digital_sqrt(625) << endl;
- //cout << gcd (6, 7) << endl;
- //cout << sum(125) << endl;
- // string a = "02020";
- // cout << polindrom(a) << endl;
- ////////////////////-task_3-///////////////
- // int buffer;
- // vector <int> seq;
- // do
- // {
- // cin >> buffer;
- // if (buffer == 0) break;
- // seq.push_back(buffer);
- // } while (buffer != 0);
- // cout << task_3(seq) << endl;
- ////////////////////-task_3-///////////////
- // int a, b;
- // cin >> a >> b;
- // cout << 'minimal number is ' << min(a, b) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement