Problem c++ emergency

Description
Convert the decimal input number N (0 ≤ N ≤ 2 147 483 647) into a base B number (2 ≤ B ≤ 9).

Input
First, the number T of test cases is given. Each test case is specified by the numbers N and B, separated by space.

Output
The converted number. The result for each test case should be printed in a separate line.

Sample Input
5
7 2
4 2
4 3
4 4
1464724260 7
Sample Output
111
100
11
10
51203644056



So erm, have you had a go at this? What is your specific question?
Hello, this can basically use to the ' itoa ' function.

http://www.cplusplus.com/reference/cstdlib/itoa/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main ()
{
    int n;
    int number, base;
    char buffer [33];
    cin>>n;
    while(n--)
    {
       cin>>number;
       cin>>base;
       itoa (number,buffer,base);
       cout<<buffer<<endl;
    }
}


regards
cronos
Topic archived. No new replies allowed.