#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
	int x, y;
	int a = 1, Result = 0, i;
	char d[41];
	cout << "adad dar mabnaye 10, x = ";
	cin >> x;
	cout << endl << "mabnaye nahaee , y = ";
	cin >> y;
	if (y != 16)
	{
		for(; x > 0; x /= y)
		{
			Result += (x % y ) * a;
			a *= 10;
		}
		cout << endl << "Natije = " << Result << endl;
	}
	else //mabnaye 16
	{
		for(i = 0; x > 0; x /= y, i++)
		{
			switch(x % y)
			{
				case 0 : d[i] = '0'; break;
				case 1 : d[i] = '1'; break;
				case 2 : d[i] = '2'; break;
				case 3 : d[i] = '3'; break;
				case 4 : d[i] = '4'; break;
				case 5 : d[i] = '5'; break;
				case 6 : d[i] = '6'; break;
				case 7 : d[i] = '7'; break;
				case 8 : d[i] = '8'; break;
				case 9 : d[i] = '9'; break;
				case 10: d[i] = 'A'; break;
				case 11: d[i] = 'B'; break;
				case 12: d[i] = 'C'; break;
				case 13: d[i] = 'D'; break;
				case 14: d[i] = 'E'; break;
				case 15: d[i] = 'F'; break;
			}
		}
		cout << endl << "Natije = ";
		for(i--; i >= 0; i--)
			cout << d[i];
	}
	getch();
}

