herrDeng網內搜尋

自訂搜尋

Ads

2011年9月22日 星期四

算gcd

計算gcd(123456789,999999999)

66 則留言:

b9733054 提到...

public class b9733054 {

/**
* @param args
*/
static int gcd(int x,int y){

int r=x%y;
if(r==0)return y;
else
return gcd(y,r);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int x=123456789;
int y=999999999;
System.out.println(gcd(x,y));

}

}

B9733200 提到...

class Program
{

static int gcd (int a, int b)
{
int r = a % b;
if (r == 0) return b;
else
return gcd(b, r);
}

static void Main(string[] args)
{
int r;
int x = 123456789,y=999999999;

{
Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();
}
}
}
}

B9933054 提到...

package pack1;
public class a1 {
public static void main(String[] args) {
int x, y;
System.out.print("最大公因函數為:");
x = 123456789;
y = 999999999;
System.out.println(gcd(x, y));
}
static int gcd(int a, int b)
{
int c = a % b;
if(c == 0)
return b;
else
return gcd(b, c);
}
}

b9933009 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

b9933034 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

b9933033 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

B9933042 提到...

public class B1 {
static int gcd(int x,int y)
{

int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}

public static void main(String[] args){

System.out.println(gcd(123456789,999999999));
}

}

B9933052 提到...

package P1;
public class B9933052A {

static int gcd(int x , int y)
{
int r =x%y;
if(r==0) return y;
else
return gcd(y,r);
}
public static void main(String[] args) {


System.out.println(gcd(123456789 , 999999999));









}

}

B9733099 提到...

static int gcd (int x,int y)
{
int r = x % y;
if (r == 0) return y;
else
return gcd (y, r);
}

static void Main(string[] args)
{
int x = 123456789, y = 999999999;
{
Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();

}

b9933039 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

B9733100 提到...

static int gcd(int a, int b)
{
int r = a % b;
if (r == 0) return b;
else
return gcd(b, r);
}
static void Main(string[] args)
{
int x = 123456789,y=999999999;
{

Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();
}

b9733115 提到...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EX3
{
class Program
{

static int gcd(int x, int y)
{
int r = x % y;
if (r == 0) return y;
else
return gcd(y, r);
}

static void Main(string[] args)
{
int x = 123456789, y = 999999999;
{
Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();

}

}
}
}

b9933018 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

b9733114 提到...

class Program
{

static int gcd(int x, int y)
{
int r = x % y;
if (r == 0) return y;
else
return gcd(y, r);
}

static void Main(string[] args)
{
int x = 123456789, y = 999999999;
{
Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();

}

}
}
}

b9933011 提到...

public class b99330114 {

static int gcd(int x,int y)
{

int r=x%y;
if(r==0)return y;
else return gcd(y,r);
}



public static void main(String[] args) {
System.out.println(gcd(123456789,999999999));

}

}

B9933055 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

B9933045 提到...

public class GCD
{
static int gcd(int x,int y)
{
int tmp;
while (x % y != 0)
{
tmp = y;
y = x % y;
x = tmp;
}
return y;
}

public static void main(String[] args)
{
System.out.println(gcd(123456789,999999999));
}
}

b9933004 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

b9933024 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

B9933041 提到...

package P1;
public class B1 {

static int gcd(int x,int y)
{
int r=x%y;
if(r==0)return y;
else return gcd(y,r);

}

public static void main(String[] args) {

System.out.println(gcd(123456789,999999999));
}

}

B9933020 提到...

package test1;
import java.util.Scanner;
public class SS1 {

public static void main(String[] args)
{





int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);






















}

}

b9733088 提到...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EX3
{
class Program
{

static int gcd(int x, int y)
{
int r = x % y;
if (r == 0) return y;
else
return gcd(y, r);
}

static void Main(string[] args)
{
int x = 123456789, y = 999999999;
{
Console.Write("GCD:");
Console.WriteLine(gcd(x, y));
Console.ReadLine();

}

}
}
}

b9933004 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933009 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933018 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

B9933048 提到...

class gcd {
public static int gcd(int m, int n) {

if(n != 0)
return gcd(n, m % n);
else return m;

}

public static void main(String[] args) {
System.out.println("GCD of (123456789,999999999) = " + gcd(123456789,999999999));
}
}

B9933003 提到...

package pack;

public class pack {
static int gcd(int x, int y)
{
int r = x%y;
if (r==0)
return y;
else
return gcd(y,r);
}
public static void main(String[] args) {

System.out.println(gcd(123456789,999999999));



}

}

b9933033 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933034 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933040 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933046 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933039 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

B9933044 提到...

package PP1;

public class GCD {

static int gcd(int x,int y)
{
int tmp;
while(x % y != 0)
{
tmp=y;
y= x%y;
x=tmp;
}
return y;
}
public static void main(String[] args) {

System.out.println(gcd(123456789,999999999));
}

}

b9933056 提到...

package b1;
public class b1 {

public static void main(String[] args) {

int m,n,gcd=0,tm,tn;
m=123456789;
n=999999999;
tm=m;
tn=n;
while(n!=0){
gcd=n;
n=m%n;
m=gcd;
}
System.out.println("("+tm+","+tn+")="+m);
}
}

B9933017 提到...

package p1;
import java.io.*;
public class A1 {

static long gcd(long x ,long y)
{
if(y==0)return x;
else
return gcd(y,x%y);
}
public static void main(String[] args) throws Exception{
long x=123456789;
long y=888888888;
long ans=gcd(x,y);
System.out.println("最大公因數"+(ans));




}

B9933023 提到...

static int gcd(int x, int y)
{
int r=x % y ;
if(r==0) return y;
else
return gcd(y,r);

}

public static void main(String[] args) {
int a, b;
System.out.print("最大公因函數為:");
a=123456789;
b=999999999;
System.out.println(gcd(a,b));
}
}

b9933005豐智偉 提到...

package P1;

public class A {

static int gcd(int x,int y)
{
int r= x % y;

if(r==0) return y ;

else

return gcd(y,r);

}
public static void main(String[] args) {
int a , b;
System.out.print("最大公因數:");
a=123456789;
b=999999999;
System.out.println(gcd(a,b));
}

}

B9933049 提到...

package P1;
import java.util.Scanner;
public class A1
{
public static void main(String[] args)
{
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=123456789;
n=999999999;
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);



}

}

b9933014 提到...

import java.util.Scanner;

public class b9933014 {
public static void main(String[] args) {


int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);





}

}

B9933020 提到...

package test1;
import java.util.Scanner;
public class SS1 {

public static void main(String[] args)
{





int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=choose.nextInt();
n=choose.nextInt();
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);























}

}

B9933054 提到...

package pack1;
public class a1 {
static int gcd(int a, int b)
{
int c = a % b;
if(c == 0)
return b;
else
return gcd(b, c);
}
public static void main(String[] args) {
int x, y;
System.out.print("最大公因函數為:");
x = 123456789;
y = 999999999;
System.out.println(gcd(x, y));
}
}

B9933038 提到...

package p1;
import java.io.*;
public class C1 {
static long gcd(long x,long y)
{

if(y==0)return x;
else
return gcd (y,x%y);
}
public static void main(String[] args)throws Exception {
long x=123456789;
long y=999999999;
long ans=gcd(x,y);
System.out.println("最大公因數="+(ans));

b9933016 提到...

package B1;

public class b2
{
static int gcd(int x,int y)
{
int r=x%y;
if(r==0)return y;
else
return gcd(y,r);
}

public static void main(String[] args)
{
int x=123456789;
int y=999999999;
System.out.println("gcd:"+ gcd(x,y));

}

}

B9933038 提到...

package p1;
import java.io.*;
public class C1 {
static long gcd(long x,long y)
{

if(y==0)return x;
else
return gcd (y,x%y);
}
public static void main(String[] args)throws Exception {
long x=123456789;
long y=999999999;
long ans=gcd(x,y);
System.out.println("最大公因數="+(ans));

B9933008 提到...

package a1;

public class a1 {

static int gcd (int a , int b)
{
int c=a % b;
if (c == 0)
return b;
else
return gcd (b,c);
}

public static void main(String[] args) {
int x,y;
System.out.print("gcd=");
x=123456789;
y=999999999;

System.out.print(gcd(x,y));
}

}

B9933015 提到...

import java.util.Scanner;

public class A1 {

public static void main(String[] args) {
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;
}

System.out.println("("+tx+","+ty+")="+x);
}
}

B9933007 提到...

import java.util.Scanner;
public class V12313213 {
public static void main(String args[]){
int x,y,temp=0,tx,ty;

x=123456789;
y=999999999;
tx=x;
ty=y;
while(y!=0){
temp=y;
y=x%y;
x=temp;

}

System.out.println("("+tx+","+ty+")="+x);

}

}

b9933028 提到...

package P1;
public class A1 {
static int gcd(int x,int y)
{
int r=x % y;
if(r==0)
return y;
else
return gcd(y,r);
}
public static void main(String[] args)
{
int x=123456789;
int y=999999999;
System.out.println("最大公因數="+gcd(x,y));
}
}

B9933036 提到...

package P1;
import java.util.Scanner;
public class A1 {


public static void main(String[] args) {


int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=123456789;
n=999999999;
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);

}

}

B9933017 提到...

package p1;
import java.io.*;
public class A1 {

static long gcd(long x ,long y)
{
if(y==0)return x;
else
return gcd(y,x%y);
}
public static void main(String[] args) throws Exception{
long x=123456789;
long y=999999999;
long ans=gcd(x,y);
System.out.println("最大公因數"+(ans));




}
}

B9933043 提到...

package P1;
import java.util.Scanner;
public class A1
{
public static void main(String[] args)
{
int m,n,temp=0,tm,tn;

Scanner choose=new Scanner(System.in);
m=123456789;
n=999999999;
tm=m;
tn=n;
while(n!=0){
temp=n;
n=m%n;
m=temp;

}

System.out.println("("+tm+","+tn+")="+m);



}

B9933050 提到...

package pack1;
public class A1 {
public static void main(String[] args) {

long a=123456789;
long b=999999999;
long ans=swap(a,b);
System.out.println(ans);
}
static long swap (long a,long b)
{
if(b==0)
return a;
else
return swap(b,a%b);

}


}

B9933019 提到...

package P1;
import java.io.*;
public class B9933019 {

static long gcd (long x,long y)
{
if (y==0)
return x;
else return gcd (y,x%y);
}
public static void main (String[]args)
{
long x=123456789;
long y=999999999;
long s=gcd(x,y);
System.out.println("最大公因數="+(s));
}
}

b9911126 提到...

public clss god
pulic static void main(Stlng[]args){
long a = 123456789
long b = 999999999
long ans=swop(a,b);
System.outy.pringln(ans);
}
static long swap (long a , long b)
{
if (b ==0)
return a;
else
return swop(b, a%b);
}
}

swapo

B9933057 提到...

package B9933057;
import java.io.*;
public class B9933057 {

static long gcd (long x,long y)
{
if (y==0)
return x;
else return gcd (y,x%y);
}
public static void main (String[]args)
{
long x=123456789;
long y=999999999;
long s=gcd(x,y);
System.out.println("最大公因數="+(s));
}
}

B9933002 提到...

package A1;

public class A1 {



public static void main(String[] args) {
long x=123456789;
long y=999999999;
long ans=swap(x,y);
System.out.println(ans);


}

static long swap(long a,long b)
{
if(b==0)
return a;
else
return swap(b,a%b);
}

}

B9733089 提到...

package pack;

public class pack {
static int gcd(int x, int y)
{
int r = x%y;
if (r==0)
return y;
else
return gcd(y,r);
}
public static void main(String[] args) {

System.out.println(gcd(123456789,999999999));



}

}

B9933001 提到...

public class B1 {



public static void main(String[] args) {
long x=123456789;
long y=999999999;
long ans=swap(x,y);
System.out.println(ans);

}
static long swap(long a,long b)
{
if(b==0)
return a;
else
return swap(b,a%b);
}
}

B9933047 提到...

package pack1;
public class A3 {
public static void main(String[] args){
long a=123456789;
long b=999999999;
long ans=smap(a,b);
System.out.println(ans);
}
static long smap(long a,long b)
{
if(b==0)
return a;
else
return smap(b,a%b);
}


}

B9933013 提到...

package pack1;
import java.io.*;
public class A1 {

static long gcd(long x,long y)
{
if(y==0)
return x;
else
return gcd (y,x%y);
}
public static void main(String[] args)
{
long x=123456789;
long y=999999999;
long s=gcd(x,y);
System.out.println("最大公因數="+(s));



}


}

B9933021 提到...

package t1;
import java.io.*;
public class t1
{
static long gcd (long x,long y)
{

if (y==0)
return x;
else
return gcd(y,x%y);
}
public static void main(String[] args)
{
long x=123456789;
long y=999999999;
long s=gcd(x,y);
System.out.println("最大公因數="+(s));





}

}

B9933025 提到...

package pack1;
public class A3 {
public static void main(String[] args){
long a=123456789;
long b =999999999;
long ans=smap(a,b);
System.out.println(ans);
}
static long smap(long a,long b)
{
if(b==0)
return a;
else
return smap(b,a% b);
}

}

B99330251 提到...

package pack1;
public class A3 {
public static void main(String[] args){
long a=123456789;
long b =999999999;
long ans=smap(a,b);
System.out.println(ans);
}
static long smap(long a,long b)
{
if(b==0)
return a;
else
return smap(b,a% b);
}

}

B9933031 提到...

package pack;

public class pack {
static int gcd(int x, int y)
{
int r = x%y;
if (r==0)
return y;
else
return gcd(y,r);
}
public static void main(String[] args) {

System.out.println(gcd(123456789,999999999));



}

}

B9933006 提到...

public class A1
{
public static void main(String[] args)
{
long a=123456789;
long b=999999999;
long ans=swap(a,b);
System.out.println(ans);
}

static long swap(long a,long b)
{
if(b==0)
return a;
else
return swap(b,a%b);
}
}

B9933051 提到...

public class B9933051
{
public static void main(String[] args)
{
long a=123456789;
long b=999999999;
long ans=swap(a,b);
System.out.println(ans);
}
static long swap(long a,long b)
{
if(b==0)
return a;
else
return swap(b,a%b);
}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章