把C语言代码转成Java代码
#include<stdio.h>#include<stdlib.h>intmain(){unsignedshorts[]={0x4500,0x0031,0x89F5,0...
#include<stdio.h>
#include<stdlib.h>
int main(){
unsigned short s[]={
0x4500,
0x0031,
0x89F5,
0x0000,
0x6e06,
0x0000,
0xdeb7,
0x455d,
0xc0a8,
0x00dc};
unsigned long i,sum=0;
for(i= 0 ; i < sizeof(s)/sizeof(short) ; i++){
sum+=s[i];
}
while(sum>>16){
sum = (sum>>16)+(sum&0xffff);
}
printf("%p",~sum);
return 0;
} 展开
#include<stdlib.h>
int main(){
unsigned short s[]={
0x4500,
0x0031,
0x89F5,
0x0000,
0x6e06,
0x0000,
0xdeb7,
0x455d,
0xc0a8,
0x00dc};
unsigned long i,sum=0;
for(i= 0 ; i < sizeof(s)/sizeof(short) ; i++){
sum+=s[i];
}
while(sum>>16){
sum = (sum>>16)+(sum&0xffff);
}
printf("%p",~sum);
return 0;
} 展开
1个回答
展开全部
package dis;
import java.io.*;
import java.math.*;
public class dis
{
public static void main(String [] s) throws Exception
{
Float a,b,c;
double x2;
double x1;
System.out.println("请输入a, b, c的值");
BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
a=Float.parseFloat(bReader.readLine());
b=Float.parseFloat(bReader.readLine());
c=Float.parseFloat(bReader.readLine());
if (b*b - 4*a*c <= 0)
System.out.println("输入的系数不对,b2-4ac不大于0!程序退出!");
else
{
x1 = (-b + Math.sqrt(b*b - 4*a*c))/2*a;
x2 = (-b - Math.sqrt(b*b - 4*a*c))/2*a;
System.out.println("x1 = "+ x1);
System.out.println("x2 = "+x2);
}
return;
}
}
import java.io.*;
import java.math.*;
public class dis
{
public static void main(String [] s) throws Exception
{
Float a,b,c;
double x2;
double x1;
System.out.println("请输入a, b, c的值");
BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
a=Float.parseFloat(bReader.readLine());
b=Float.parseFloat(bReader.readLine());
c=Float.parseFloat(bReader.readLine());
if (b*b - 4*a*c <= 0)
System.out.println("输入的系数不对,b2-4ac不大于0!程序退出!");
else
{
x1 = (-b + Math.sqrt(b*b - 4*a*c))/2*a;
x2 = (-b - Math.sqrt(b*b - 4*a*c))/2*a;
System.out.println("x1 = "+ x1);
System.out.println("x2 = "+x2);
}
return;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询