2015年3月12日 星期四

[2015][Quiz][Week03] Quiz02 - 60373012H



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

namespace 
{
    class Program
    {
        static void Main(string[] args)
        {
            string q;
            int sum, a, b, c, d,

            for (sum = 1000; sum <= 9999; sum++)
            {
                d = sum % 10;
                c = (sum % 100 - d) / 10;
                b = (sum % 1000 - 10 * c - d) / 100;
                a = (sum % 10000 - 100 * b - 10 * c - d) / 1000;
                total = (10 * a + b) * (10 * a + b) + (10 * c + d) * (10 * c + d);
                if (sum == total)

                    Console.WriteLine("{0}", total);

            }

            }


        }

沒有留言:

張貼留言