参考代码:
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语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)for循环浏览:1146 |
A+B for Input-Output Practice (VII) (C++代码)浏览:628 |
A+B for Input-Output Practice (C++代码)浏览:613 |
分糖果 (C++代码)浏览:1463 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:781 |
【亲和数】 (C语言代码)浏览:521 |
【偶数求和】 (C语言代码)浏览:656 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1317 |
简单的a+b (C语言代码)浏览:542 |