题解 | #牛群编号转换#
牛群编号转换
https://www.nowcoder.com/practice/6a5ed8ca0a454e3a93f5e2b2e7502651
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param num int整型
* @return string字符串
*/
public String convert_to_base6 (int num) {
// write code here
int x=num;
if(num<0) x=-num;
if(x==0) return "0";
String ans="";
while(x!=0){
ans=x%6+ans;
x=x/6;
}
return num>0?ans:"-"+ans;
}
}
海康威视公司福利 1125人发布