参考代码:
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语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:726 |
点我有惊喜!你懂得!浏览:2076 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:687 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:594 |
蓝桥杯历届试题-九宫重排 (C++代码)浏览:2786 |
【绝对值排序】 (C++代码)浏览:691 |
人见人爱A+B (C语言代码)浏览:635 |
WU-小九九 (C++代码)浏览:1687 |
用筛法求之N内的素数。 (C语言代码)浏览:861 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:553 |