大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
修改成Java后的代码:
创新互联专业为企业提供桐庐网站建设、桐庐做网站、桐庐网站设计、桐庐网站制作等企业网站建设、网页设计与制作、桐庐企业网站模板建站服务,十年桐庐做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
public class Demo {
public static int gcd(int a, int b, int c) {
int min, i;
if(a b) {
if(b c) {
min = c;
} else {
min = b;
}
} else {
if(a c) {
min = c;
} else {
min = a;
}
}
if(b c) {
if(c a) {
min = a;
} else {
min = c;
}
} else {
if(b a) {
min = a;
} else {
min = b;
}
}
if(a c) {
if(c b) {
min = b;
} else {
min = c;
}
} else {
if(a b) {
min = b;
} else {
min = a;
}
}
for(i=min; i=1; i--) {
if(a%i==0 b%i==0 c%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(a 9) {
b = 1;
while(b 9) {
c = 1;
while(c 9) {
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(z 0) {
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);
}
}
你要把这个转为java程序么?
package org.crazyit.app.ServletAPI;
import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
char [] ax={'1','2'};
char[] ac = reverse(ax);
System.out.println(Arrays.toString(ac));
char sz[] = new char[128];
System.out.println("请输入你要转换的数 : ");
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
System.out.println("请输入进制 : ");
int c = scanner.nextInt();
cover_to(n, c, sz);
System.out.println("转换成 " + c + "进制是 :" + Arrays.toString(sz));
}
public static void cover_to(int num, int base, char sz[]) {
int t = num;
int r = 0;
int n = 0;
int i = 0;
if (base 2 || base 32) {
return;
}
while ((n = t / base) != t) {
r = t % base;
t = n;
if (r 9)
sz[i++] = (char) ('A' + (r - 10));
else
sz[i++] = (char) ('0' + r);
}
sz[i] = 0;
reverse(sz);
}
public static char [] reverse(char [] arr) {
int end= arr.length-1;
int begin =0;
while(begin end){
char temp = arr[begin];
arr[begin] = arr;
arr = temp;
begin++;
end--;
}
return arr;
}
}
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;
}
}