利用goto,算出最大公因數


            int number1=54, number2=24,number3=0;
            int temporarily = Math.Max(number1, number2);
            number2  = Math.Min(number1, number2);
            number1 = temporarily;
            while1:
            number1 = number1 > number2 ? number1 : number2;
            number3 = number1 % number2;
            number1 = number2;
            number2 = number3;
            if (number2 != 0)
                goto while1;
            Console.Write(number1);

沒有留言:

張貼留言