Advertisement
LEGEND2004

Digits

Aug 31st, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define double long double
  7. #define endl '\n'
  8. #define fastio ios_base::sync_with_stdio(0); cin.tie(0)
  9.  
  10.  
  11. signed main()
  12. {
  13.     fastio;
  14.  
  15.     int n;
  16.     cin >> n;
  17.     n = abs(n);
  18.     int m = 0; // tersine
  19.     int cnt = 0; // reqem sayi
  20.     int sum = 0; // reqem cemi
  21.     int hasil = 1; // reqemlerin hasili
  22.     int x = 9; // min reqem, baslayanda 9 la
  23.     int y = 0; // max reqem, baslayanda 0 la
  24.     while(n){
  25.         int d = n % 10;
  26.         m = m * 10 + d;
  27.         cnt++;
  28.         sum += d;
  29.         hasil *= d;
  30.         x = min(x , d);
  31.         y = max(y , d);
  32.         n /= 10;
  33.     }
  34.     // -94582
  35.     cout << "Tersine: " << m << '\n'; // 28549
  36.     cout << "Say: " << cnt << '\n'; // 5
  37.     cout << "Cem: " << sum << '\n'; // 28
  38.     cout << "Hasil: " << hasil << '\n'; // 2880
  39.     cout << "Min: " << x << '\n'; // 2
  40.     cout << "Max: " << y << '\n'; // 9
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement