Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- ///trecere din baza 10 in b cu functii
- int trecere10_b(int x10, int b)
- {
- int p10,c,xb=0;
- p10=1;
- while(x10)
- {
- c=x10%b;
- xb=xb+c*p10;
- p10=p10*10;
- x10=x10/b;
- }
- return xb;
- }
- ///trecere din baza b in 10 cu functii
- int trecereb_10(int n,int b)
- {
- int p=1,m=0,c;
- while(n)
- {
- c=n%10;
- m=m+c*p;
- p=p*b;
- n=n/10;
- }
- return m;
- }
- int main()
- {
- int numar,baza,raspuns,raspuns2;
- cin>>numar>>baza;
- raspuns2=trecereb_10(numar, baza);
- cout<<raspuns2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement