lzth.net
当前位置:首页 >> 编写一个JAvA程序输入一个8位二进制数输出一个10进制数 >>

编写一个JAvA程序输入一个8位二进制数输出一个10进制数

//编写一个Java程序输入一个8位二进制数输出一个10进制数import java.util.Scanner;public class Day05 {static Scanner sc=new Scanner(System.in);public static void main(String[] args) {String str="a";while(true) {System.out.print("输入二进制

unsigned int _atoi(unsigned int n,char* str,unsigned int len) { unsigned int step; step = n if (step { str[step] = n%10+ '0'; str[++step] = 0; return step; } else { return len; } } 使用方式:char str[32]; int len=_atoi(123456789,str,32); 说明:只实现了无符号数的转换,有符号数,可以稍微改一下,而且只是10进制的数,其它进制的数也可以稍改一下,返回的长度包含字符串的结束符0

你好,程序如下: import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader; public class JZ { public static void main(String[] args) throws IOException{ BufferedReader bfr = new BufferedReader(new

import java.util.scanner;public class test { public static void main(string[] args) { scanner scan=new scanner(system.in); system.out.println("请输入一个十进制数:"); int num=scan.nextint(); system.out.println("转换为二进制:"+integer.tobinarystring(num)); scan.close(); }}

#include int main() { int num2=0; int num10=0; int wei[100]={0}; scanf("%d",&num2); int i=0; printf("您输入的二进制数为:%d\n",num2); while(num2) { wei[i]=num2%10; i++; num2=num2/10; } for(int j=0;j { if (wei[j]==1) { num10+=wei[j]*(pow(

#include using namespace std;//计算x的n次方 double power (double x, int n); int main() { int value = 0; cout for (int i = 7; i >= 0; i--) { char ch; cin >> ch; if (ch == '1') value += static_cast(power(2, i)); } cout cout return 0; }/**********begin****************

现写一个,绝对原创!main(){int m,i;char s[100];scanf("%d",&m);for(i=98,s[99]='\0';m;i--){s[i]=(char)(48+m%2);m/=2;}printf("%s\n",s+i+1);}

public class Calc extends Frame implements ActionListener { TextField text1, text3, text4, text5; Button btn; public Calc() { setLayout(new GridLayout(7, 3)); // 第一行 text1 = new TextField(10); add(text1); btn = new Button("do"); btn.

assume cs:code,ds:data,ss:stack stack segment stack db 256 dup (0) stack ends data segment str1 db "Input 8-bit Binary: ",'$' str2 db 10,13,"Decimal: ",'$' str3 db 10,13,"Press any key to exit",'$' d db 0,0,0,'$' data ends code segment

import javax.swing.JOptionPane;public class test01 { public static void main(String sgs[]) { String num = JOptionPane.showInputDialog("请输入要转换的数字:"); int number = Integer.parseInt(num); System.out.println("该数的二进制数值

gmcy.net | mydy.net | 5689.net | qhgj.net | qmbl.net | 网站首页 | 网站地图
All rights reserved Powered by www.lzth.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com