Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://www.pbinfo.ro/?pagina=probleme&id=946
- #include <iostream>
- using namespace std;
- int reversed(int numar)
- {
- int n = 0;
- while(numar)
- {
- n += numar % 10;
- n *= 10;
- numar /= 10;
- }
- return n / 10;
- }
- int bazaX(int numar, int baza)
- {
- int n = 0;
- while(numar)
- {
- n += numar % baza;
- n *= 10;
- numar /= baza;
- }
- n /= 10;
- return n;
- }
- int bazaTen(char sir[])
- {
- int n = 0;
- for(int i = 0; i < 6; i++)
- {
- n += sir[i] - '0';
- n *= 2;
- }
- n /= 2;
- return n;
- }
- int main()
- {
- int baza = 4;
- char sir[6] = {'1', '0', '0', '0', '1', '1'}; //caz particular
- int ten = bazaTen(sir);
- cout << "Baza 2: " << ten << endl;
- int bazaN = bazaX(ten, baza);
- cout << "Inainte: " << bazaN << endl;
- cout << reversed(bazaN);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement