c代码转java c代码转换成汇编( 二 )


}
如果是意译(计算int数组的所有数之和),那么java可以这样写
public int accumulativeVerification(int[] data) {
int sum = 0;
for (int i = 0; idata.length; i++) {
sum += data[i];
}
return sum;
}
把C语言代码转成Java代码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, cc代码转java的值");
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("输入的系数不对c代码转java,b2-4ac不大于0c代码转java!程序退出c代码转java!");
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;
}
}
怎样把一下的C语言程序改成java程序?修改成Java后c代码转java的代码c代码转java:
public class Demo {
public static int gcd(int a, int b, int c) {
int min, i;
if(ab) {
if(bc) {
min = c;
} else {
min = b;
}
} else {
if(ac) {
min = c;
} else {
min = a;
}
}
if(bc) {
if(ca) {
min = a;
} else {
min = c;
}
} else {
if(ba) {
min = a;
} else {
min = b;
}
}
if(ac) {
if(cb) {
min = b;
} else {
min = c;
}
} else {
if(ab) {
min = b;
} else {
min = a;
}
}
for(i=min; i=1; i--) {
if(a%i==0b%i==0c%i==0) {
break;
}
}
return i;
}
public static void main(String[] args) {
int a = 1, b = 0, c = 0, i, k = 0, j = 0, m = 0, n = 0, z, y;
while(a9) {
b = 1;
while(b9) {
c = 1;
while(c9) {
if(gcd(a,b,c) == 1) {
System.out.println(a + ";" + b + ";" + c);
k++;
z = b*b - 4*a*c;
if(z == 0) {
j++;
} else if(z0) {
m++;
for (y=1; yz/2; y++) {
if (y*y==z) {
System.out.println("解答是有理数 。");
}
}
} else {
n++;
}
}
c++;
}
b++;
}
a++;
}
System.out.println("N = " + k);
System.out.println("N2 = " + j);
System.out.println("N3 = " + m);
System.out.println("N4 = " + n);
i = gcd(a, b, c);
}
}
【c代码转java c代码转换成汇编】关于c代码转java和c代码转换成汇编的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读