关于进制转换的有关问题,求进,大牛

关于进制转换的问题,求进,在线等大牛
编写一个程序,输入三个整数n A B,表示把A进制的n,转换为B进制,并输出。
样例:
输入 输出
11 8 10 9
129 10 2 10000001
22 3 6 12

假定输入的A和B都在2-10这个范围,超出范围的不用去处理,输入的n保证在int范围内。
如题,求代码!!!!

------解决方案--------------------
C/C++ code
#include <iostream>
#include <cmath>
#include <string>
using namespace std;


void func(string n,int A,int B)
{
    int real=0;
    int i;
    for (i=0;i<n.length();i++)
    {
        real=real*A+int(n[i]-'0');
    }

    string taget;
    while (real>0)
    {
        taget=char('0'+real%B)+taget;
        real/=B;
    }

    cout<<taget<<endl;
}
int main()
{
    string number;
    int A,int B;
    while (cin>>number>>A>>B)
    {
        func(number,A,B);
    }
}

------解决方案--------------------
探讨

引用:
我也是新手
不过调试过了


C/C++ code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 幂函数
int pow(int a, int n)
{
if (0==n) return 1;
else return a*pow(a,n-1);
}

// ……