2015年3月12日 星期四

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

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

namespace _40173037H_quiz2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("========第一題==========");
            int i;
            int a,a_,b,b_,c,d;
            for (i = 1000; i <= 9999; i++)
            {
                a = i / 100; b = i % 100;
                
                if (i == (a*a+b*b))
                    Console.WriteLine("{0}", i);
            }
            Console.WriteLine("================第二題===============");
            int j;
           
            for (j = 1; j <= 999999; j++)
            {
                if (j <= 99)
                { 
                    if (j==(j%100))
                    Console.WriteLine("{0}",j);
                    
                }
                else if((j>99)&&(j<=9999))
                {
                    if (j == (j / 100) * (j / 100) + (j % 100) * (j % 100))
                        Console.WriteLine("{0}", j);


                }
                else if ((j > 9999) && (j <= 999999))
                {
                    if (j == ((j / 10000) * (j / 10000) * (j / 10000) + ((j % 10000) / 100) * ((j % 10000) / 100) * ((j % 10000) / 100) + ((j % 10000) % 100) * ((j % 10000) % 100) * ((j % 10000) % 100))) 
                    Console.WriteLine("{0}",j);
                }
            }
                Console.Read();
        }
    }
}

沒有留言:

張貼留言