Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- int cifre(int n) {
- if (n == 0) return 0;
- return 1 + cifre(n / 10);
- }
- // Rasturnatul
- int rast(int n, int p) {
- if (n == 0) return 0;
- return (n % 10) * pow(10, p) + rast(n / 10, p - 1);
- }
- // N nr. suma
- int numar(int n) {
- if (n == 0) return 0;
- int x; cin >> x;
- return x + numar(n - 1);
- }
- // divizor care conform algo euclid va calcula divizorul comun, 0 si 0 nu exista
- int gcd(int a, int b) {
- if (b == 0)
- return a;
- return gcd(b, a % b);
- }
- int32_t main() {
- int n, m, a, b, x;
- cin >> n >> m >> a >> b;
- cout << "cifre(n) = " << cifre(n) << endl;
- cout << "cifre(m) = " << cifre(m) << endl;
- cout << "rast(n) = " << rast(n, cifre(n) - 1) << endl;
- cout << "rast(m) = " << rast(m, cifre(m) - 1) << endl;
- cout << "numar(n) = " << numar(n) << endl;
- cout << "euclid(a, b) = " << gcd(a, b) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement