UVa 389 - Basically Speaking

Summary
You have to create a conversion for a number in a given base to a number in another base. If the output exceeds 7 characters then you have to print error.

Explanation
The easiest way is to convert to base 10 and to convert to the second base. Here is the psuedo code: n is the number. do res=n%base  /*fix base after this ie base >=10*/ n=n/base; while( n != 0)

reverse(result) /*reverse the string*/

Gotchas
The 7 digit output should be right justified.

Input
1111000 2 10 1111000  2 16 2102101       3 10        2102101  3 15  12312  4  2     1A 15  2 1234567 10 16  ABCD 16 15 000 12 12

Output
120    78   1765    7CA ERROR 11001 12D687 D071 0