用stack栈写的,90分
查看原帖
用stack栈写的,90分
772351
fantastic_grass楼主2023/12/3 15:18
#include<bits/stdc++.h>
using namespace std;
int n,d;
stack<char> s;
string sum="0123456789ABCDEF";
int main(){
	cin>>n>>d;
	if(n==0){
		cout<<0;
		return 0;
	}
	while(n!=0){
		s.push(sum[n%d]);
		n/=d;
	}
	while(!s.empty()){
		cout<<s.top();
		s.pop();
	}
	return 0;
}
2023/12/3 15:18
加载中...