Advertisement
Josif_tepe

Untitled

Apr 11th, 2023
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.    
  6.     int broj;
  7.     cin >> broj;
  8.    
  9.     int orginalna_vrednost = broj;
  10.    
  11.     int kolku_cifri = 0;
  12.     while(broj > 0) {
  13.         kolku_cifri++;
  14.         broj /= 10;
  15.     }
  16.     broj = orginalna_vrednost;
  17.     if(kolku_cifri % 2 == 1) {
  18.         int koja_cifra = kolku_cifri / 2 + 1;
  19.        
  20.         int sredna_cifra;
  21.        
  22.         while(koja_cifra > 0) {
  23.             sredna_cifra = broj % 10;
  24.             broj /= 10;
  25.             koja_cifra--;
  26.         }
  27.         cout << sredna_cifra << endl;
  28.     }
  29.     else {
  30.         cout << broj << endl;
  31.     }
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement