参考代码:
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语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:724 |
兰顿蚂蚁 (C++代码)浏览:1091 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:762 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:577 |
简单的a+b (C语言代码)浏览:523 |
最小公倍数 (C语言代码)浏览:1025 |
关于C语言变量位置的问题浏览:272 |
数对 (C语言代码)浏览:697 |
1017题解浏览:572 |
DNA (C语言代码)浏览:390 |