你要把这个转为java程序么?
package org.crazyit.app.ServletAPIimport 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[end]
arr[end] = temp
begin++
end--
}
return arr
}
}
修改成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 y<z/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)
}
}
public class Test{public staitc void main(String args){
int i,j,k=3
for(i=0i<4k=k-1-i,i++)
{
for(j=0j<4+ij++)
{
if(j<k)
System.out.print(" ")
else
{
System.out.print("弯简*"信喊)
j++
}
}
}
k=3
}
}
保滑闹野存为Test.java,然后运行javac Test.java和java Test就可以运行了。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)