import java.util.Scanner; import java.util.Vector; public class Main {     static public void main(String[] args) {         Scanner in = new Scanner(System.in);         int n = in.nextInt();         in.nextLine();         while (n-- > 0) {             // 第一次 补齐0             String string = in.nextLine();             if (string.length() % 3 == 1) {                 string = "00" + string;             } else if (string.length() % 3 == 2) {                 string = "0" + string;             }             // 将十进制转换成2进制             Vector<String> vector = new Vector<>();             int threeNum = string.length() / 3;             String tenStr = "";             for (int i = 0; i < threeNum; i++) {                 String temp = string.substring(i * 3, i * 3 + 3);                 temp = Integer.toString(Integer.parseInt(temp), 2);                 int tempLen = temp.length();                 for (int j = 0; j < 10 - tempLen; j++) {                     temp = "0" + temp;                 }                 tenStr = tenStr + temp;             }             // 去掉前导零             int tenStrLen = tenStr.length();             String tempStr = tenStr;             for (int i = 0; i < tenStrLen; i++) {                 if (tenStr.charAt(i) == '0') {                     tempStr = tenStr.substring(i + 1, tenStrLen);                 } else {                     break;                 }             }             tenStr = tempStr;             tenStrLen = tenStr.length();             for (int i = 0; i < tenStrLen; i++) {                 if (tenStr.charAt(i) == '0') {                     tempStr = tenStr.substring(i + 1, tenStrLen);                 } else {                     break;                 }             }             tenStrLen = tenStr.length();             int howManyFive = tenStr.length() % 5;             if (howManyFive != 0) {                 while (howManyFive++ < 5) {                     tenStr = "0" + tenStr;                 }             }             String result = "";             tenStrLen = tenStr.length();             int fiveTime = tenStrLen / 5;             while (fiveTime-- > 0) {                 result = Integer.toString(Integer.parseInt(tenStr.substring(5 * fiveTime, 5 * fiveTime + 5), 2), 32)                         + result;             }             System.out.println(result.toUpperCase());         }     } } 第二题 可以优化的点太多了……懒得继续优化了
点赞 1

相关推荐

05-12 11:09
已编辑
门头沟学院 后端
已注销:没必要放这么多专业技能的描述。这些应该是默认已会的,写这么多行感觉在凑内容。项目这块感觉再包装包装吧,换个名字,虽然大家的项目基本都是网上套壳的,但是你这也太明显了。放一个业务项目,再放一个技术项目。技术项目,例如中间件的一些扩展和尝试。
点赞 评论 收藏
分享
嵌入式小辣鸡:包装好一点,校内的奖项可以不用写,校内项目经历最后两点写的太差了,详细讲一下内容,名字变一下。只需要写项目实现了什么,自己在其中做了什么就好,查看图片
点赞 评论 收藏
分享
牛客网
牛客企业服务