修改成Java后的代碼:
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供桐廬網(wǎng)站建設(shè)、桐廬做網(wǎng)站、桐廬網(wǎng)站設(shè)計(jì)、桐廬網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、桐廬企業(yè)網(wǎng)站模板建站服務(wù),十年桐廬做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
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("解答是有理數(shù)。");
}
}
}?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);
}
}
你要把這個(gè)轉(zhuǎn)為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("請輸入你要轉(zhuǎn)換的數(shù)?:?");
Scanner?scanner?=?new?Scanner(System.in);
int?n?=?scanner.nextInt();
System.out.println("請輸入進(jìn)制?:?");
int?c?=?scanner.nextInt();
cover_to(n,?c,?sz);
System.out.println("轉(zhuǎn)換成?"?+?c?+?"進(jìn)制是?:"?+?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("輸入的系數(shù)不對,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;
}
}