参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(p(scanner.nextLine())); } public static String p(String s) { if(s.charAt(0) == '0') return s; char []s1 = s.toCharArray(); String s2 = "1"; for(int i = 1; i < 16; i++) { if (s1[i] == '0') s1[i] = '1'; else s1[i] = '0'; s2 += s1[i] - '0'; } int s3 = Integer.parseInt(s2, 2); s3++; String res = Integer.toBinaryString(s3); return res; } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:618 |
兰顿蚂蚁 (C++代码)浏览:1091 |
哥德巴赫曾猜测 (C语言代码)浏览:1013 |
大小写转换 (C语言代码)浏览:858 |
字符串的输入输出处理 (C语言代码)浏览:944 |
【蟠桃记】 (C语言代码)浏览:664 |
WU-C语言程序设计教程(第三版)课后习题11.11 (C++代码)(想学链表的可以看看)浏览:1357 |
演讲大赛评分 (C语言代码)浏览:1634 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:687 |
盐水的故事 (C语言代码)浏览:1528 |