import java.util.Scanner;public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);while (sc.hasNext()) {
char[] set = {
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};int decimal = sc.nextInt(); //十进制数字int base = sc.nextInt(); //需要转换的进制int[] result = new int[1007];//处理负数if(decimal < 0) {
System.out.print("-");decimal = -decimal;}int cnt = 0;while (decimal != 0){
int temp = decimal % base;decimal = decimal / base;result[cnt++] = temp;}for (int i = cnt-1; i >= 0; i--) {
System.out.print(set[result[i]]);}System.out.println();}}
}
详细解决方案
HDU-2031
热度:76 发布时间:2023-11-27 03:56:41.0
相关解决方案
- HDU-2031
- POJ 2031 Building a Space Station(最小生成树)
- POJ 2031 Building a Space Station (最小生成树,裸题)
- HDOJ--2031
- poj-2031-Building a Space Station-球心最短路
- 杭电ACM基础题(2031、2032、2033、2034、2035、2039、2040、2042、2043、2051)
- 【PAT 1033】【codeup 2031】To Fill or Not to Fill
- POJ - 2031 Building a Space Station
- Building a Space Station -POj 2031(最小生成树 详解注释)
- POJ 2031 Building a Space Station G++ 最小生成树 Kruskal实现 prim未实现