#include"bits/stdc++.h"
#include<conio.h>
#include<time.h>
#include<windows.h>
using namespace std;
void hide(bool b) {
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = b; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);
}
#define black 0
#define blue 1
#define green 2
#define lightBlue 3
#define red 4
#define purple 5
#define yellow 6
#define white 7
#define gray 8
#define lightGreen 10
#define whiteGreen 11
#define pink 12
#define lightPurple 13
#define lightYellow 14
#define lightWhite 15
void color(int fore=7,int back=0) {
unsigned char m_color = fore;
m_color += (back << 4);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), m_color);
}
int n,scale;
string s=" ";
int main() {
hide(0);
cin>>n>>scale;
color(scale);
while(n!=0){
string ss=to_string(n%scale);
s=ss+s;
n/=scale;
}
cout<<s;
return 0;
}
其实就是倒取余数法,先让,用字符串
保存刚刚的
,再加入到答案字符串
内,最后输出
。