题解 | #牛群编号转换#

牛群编号转换

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;
    }
}

全部评论

相关推荐

07-05 16:23
门头沟学院 Java
mengnankk:我投了300,约了5 6个面试。感觉项目写的太多了。一个项目就写五六个亮点,不是把整个项目的功能描述下。其他的没啥,简历看起来有点长
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务