2015年3月14日 星期六
2015年3月12日 星期四
[2015][Quiz][Week03] Quiz2 - 60373006H
namespace practice
{
class Test
{
static void Main(string[] args)
{
Console.WriteLine("ex.1\n");
int nfront;
int nbehind;
int temp = 0 , temp2=0;
int segment = 1;
int sum =0;
for (int i = 1000; i <= 9999; i++)
{
nfront =i / 100;
nbehind = i % 100;
if (i == Math.Pow(nfront, 2.0) + Math.Pow(nbehind, 2.0))
Console.WriteLine("{0}", i);
}
Console.WriteLine("==============我是分隔線===============");
Console.WriteLine("ex.2\n");
for (int i = 1; i <= 999999; i++)
{
temp = i; //處理次方
while (temp / 100 > 0)
{
segment++;//累計次方數
temp/=100;//Ex:5位數字除以100可除3次
} //處理次方
temp = i; //分割數字
for (int j = 1; j <= segment; j++) //設定<=次方數為中止條件
{
temp2 = temp % 100; //因為沒法直接"(int)Math.Pow((double)temp % 100, (double)segment)",所以需要第二個暫存"取尾數"
temp /= 100; //將取過尾數的第一暫存砍掉尾數
sum += (int)Math.Pow((double)temp2, (double)segment); //做相加
} //分割數字
if (i == sum) //判斷式
Console.WriteLine("{0}", i);
temp = 0;
sum = 0;
segment = 1;
}
Console.ReadKey();
}
}
}
[2015][Quiz][Week03] Quiz2 - 40173038H
Quiz2_1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num;
int ans;
for(num=1000;num<=9999;num++)
{
int a = num % 100;
int b = num / 100;
if (num==(a*a)+(b*b))
Console.WriteLine("Answer = {0}",num);
}
Console.ReadKey();
}
}
}
Quiz2_2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace week3
{
class Program
{
static void Main(string[] args)
{
int n;
int a = 0;
int temp;
for (n = 1000; n <= 999999; n++)
{
double sum = 0;
double p = 0;
temp = n;
while (temp != 0)
{
temp = temp / 100;
p++;
}
temp = n;
while (temp != 0)
{
a = temp % 100;
sum += Math.Pow((double)a, (double)p);
temp /= 100;
}
if (sum == n)
{
Console.WriteLine("Anwer = {0}", sum);
}
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173007H
namespace _40173007h_quiz2
{
class Program
{
static void Main(string[] args)
{
string q;
int sum,a,b,c,d,total,triple,s,e, num;
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);
}
for (s = 100000; s <= 999999; s++)
{
num = 0;
triple = s;
while (triple % 100 != 0)
{
e = triple % 100;
triple/= 100;
num += e * e * e;
}
if(num==s)
Console.WriteLine("{0}", num);
}
Console.ReadKey();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173034H
quiz2_1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num,a,b;
for(num=1000;num<=9999;num++)
{
a = num % 100;
b = num / 100;
while(num == (a*a)+(b*b))
{
Console.WriteLine("{0}",num);
break;
}
}
Console.ReadKey();
}
}
}
quiz2_2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _40173034H_Quiz2_2
{
class Program
{
static void Main(string[] args)
{
int num;
int a = 0;
for(num=1000;num<=999999;num++)
{
double sum = 0;
int temp;
double s=0;
temp = num;
while(temp!=0)
{
temp = temp / 100;
s++;
}
temp = num;
while(temp!=0)
{
a = temp % 100;
sum += Math.Pow((double)a, (double)s);
temp = temp / 100;
}
if(sum==num)
{
Console.WriteLine("{0}",num);
}
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173008H
第一題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1000; i < 9999; i++)
{
int a=0;
int b=0;
a=i%100;
b=i/100;
if(a*a+b*b==i)
Console.WriteLine("{0}",i);
};
Console.Read();
}
}
}
第二題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int temp = 0;
int a=0;
for (int i = 1; i <= 999999; i++)
{
temp = i;
int segments = 0;
double sum = 0;
while (temp != 0)
{
temp /= 100;
segments++;
}
temp = i;
while (temp != 0)
{
a = temp % 100;
sum += Math.Pow((double)a, (double)segments);
temp /= 100;
}
if (i == sum)
Console.WriteLine("{0}", i);
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173044H
Quiz2_1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int sum = 0;
for(int i=1000;i<=9999;i++)
{
d = i % 10;
c = i/10 % 10;
b = i/100 % 10;
a = i/1000 % 10;
sum = (10 * a + b) * (10 * a + b) + (10 * c + d) * (10 * c + d);
if(sum==i)
Console.WriteLine("{0}",i);
}
Console.ReadLine();
}
}
}
Quiz2_2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int k = 0;
int s = 0;
double sum = 0;
int temp=0;
int[] array = new int[5];
for(int i=1000;i<=999999;i++)
{
temp=i;
for(k=0;k<100;k++)
{
array[k]=temp%100;
if (temp%100==0)
{
break;
}
temp=temp/100;
}
sum = 0;
for (int time = 1; time < k+1; time++)
sum += Math.Pow((double)array[time - 1], (double)k);
if (sum == i)
Console.WriteLine("{0}",i);
}
Console.ReadLine();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173032H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i,s,k;
for (i = 2; i <= 9999; i++) //Quiz2-第一題
{
if ((i / 100) * (i / 100) + (i % 100) * (i % 100) == i)
Console.WriteLine("{0}", i);
}
for (s = 10000; s <= 999999; s++) //Quiz2-第二題
{
k=(s%100)*(s%100)*(s%100)+(s%10000/100)*(s%10000/100)*(s%10000/100)+(s/10000)*(s/10000)*(s/10000);
if (k == s)
Console.WriteLine("{0}", k);
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40073049H
第一題:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int a,b;
for(int Num=1000;Num<10000;Num++)
{
a=Num/100;
b=Num%100;
if (Num == (a * a + b * b))
{
Console.WriteLine("輸出結果:");
Console.WriteLine("{0}", Num);
}
}
Console.ReadKey();
}
}
}
第二題:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program2
{
static void Main(string[] args)
{
Console.WriteLine("請輸入上限值:");
int Num2 = int.Parse(Console.ReadLine());
Console.WriteLine("結果:");
for (int Num1=100;Num1<=Num2;Num1++)
{
int temp=Num1,k=0;
double sum = 0;
while(temp!=0)
{
temp/=100;
k++;
}
temp = Num1;
int a = 0;
while (temp != 0)
{
a=temp%100;
sum +=Math.Pow((double)a,(double)k);
temp /= 100;
}
if (Num1 == sum)
Console.WriteLine("{0}", sum);
}
Console.ReadKey();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40073037H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1000; i <= 9999; i++) {
int one = i / 100;
int two = i % 100;
int sum = one * one + two * two;
if(sum==i)
Console.WriteLine(sum);
}
Console.ReadKey();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173041H
Quiz2_1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quiz2
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int b = 0;
int num = 0;
for(int i=1000;i<=9999;i++)
{
a = i / 100;
b = i % 100;
if (i==(a*a+b*b))
Console.WriteLine("{0}",i);
}
Console.ReadLine();
}
}
}
Quiz2_2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quiz2_2
{
class Program
{
static void Main(string[] args)
{
long sum = 0;
long num = 0;
for (long i = 1002; i <= 1000000000; i++)
{
num = i;
sum = (i%100)*(i%100)*(i%100);
while (num >= 100)
{
sum = sum + ((num/100)%100)*((num/100)%100)*((num/100)%100);
num = num / 100;
} ;
if (sum == i)
Console.WriteLine("{0}", i);
}
Console.ReadLine();
}
}
}
[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);
}
}
}
[2015][Quiz][Week03] Quiz02 - 40075040H
01.
//可將程式碼放於此處,請至文章的html模式編輯
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
class Program
{
static public void CMP(int num)
{
int first, second;
first = num / 100;
second = num % 100;
if (num == (first * first) + (second * second))
Console.WriteLine(num);
}
static void Main(string[] args)
{
// int i;
for (int i = 1000; i <= 9999; i++)
{
Program.CMP(i);
}
Console.Read();
}
}
}
02.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test2
{
class Program
{
static void Main(string[] args)
{
int buffer, now, var, num, c = 0;
now = 0;
//scan=Convert.ToInt32 (Console.ReadLine());
for (int scan = 100; scan <= 100000000; scan++)
{
buffer = scan;
c = 0;
now = 0;
var = 100 * scan;
num = scan;
for (int i = 0; num > 0; i++)
{
num = num / 100;
c++;
}
for (int i = 0; var > 0; i++)
{
var = var / 100;
buffer = var % 100;
buffer = Convert.ToInt32(Math.Pow(Convert.ToDouble(buffer), Convert.ToDouble(c)));
now += buffer;
}
if (scan == (now))
Console.WriteLine(scan);
} Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173035H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num;
int a;
int b;
int f;
for(num=1000;num<=9999;num++)
{
a=num%100;
b=num/100;
f=a*a+b*b;
if (num==f)
Console.WriteLine("{0}", a*a+b*b);
}
Console.Read();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num;
int a;
int b;
int f;
int c;
for(num=100000;num<=999999;num++)
{
a=num%100;
b=num/10000;
c=num/100-b*100;
f=a*a*a+b*b*b+c*c*c;
if (num==f)
Console.WriteLine("{0}", a * a * a + b * b * b + c * c * c);
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173022H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, a, b,c;
for(num=1000; num<=9999; num++)
{
a=num/100;
b=num%100;
c=a*a+b*b;
if (num == c)
Console.WriteLine("{0}", num);
}
Console.Read();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int num;
double sum = 0;
int temp = 0;
int segments;
for (num=1; num<=999999; num++)
{
temp = num;
sum = 0;
segments = 0;
while (temp != 0)
{
temp /= 100;
segments++;
}
temp = num;
while (temp != 0)
{
a = temp % 100;
sum += Math.Pow((double)a, (double)segments);
temp /= 100;
}
if (num == sum)
Console.WriteLine("{0}", num);
}
Console.Read();
}
}
}
[2015][Quiz][Week03] Quiz02 - 60373020H
Quiz02-1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quiz2_1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("從1000到9999:ABCD=(AB)^2+(cd)^2");
Console.WriteLine("================");
for (int i = 1000; i <= 9999; i++)
{
int a = i % 100;
int b = i / 100;
if (i == a * a + b * b)
{
Console.WriteLine("{0}", i);
}
}
Console.ReadKey();
}
}
}
Quiz02-2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quiz2_2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入一個數");
Console.WriteLine("================");
int x = int.Parse(Console.ReadLine());
if (x / 100 == 0)
{
Console.WriteLine("輸入錯誤");
}
if (x / 100 < 100)
{
for (int i = 1000; i <= x; i++)
{
int a = i % 100;
int b = i / 100;
if (i == a * a + b * b)
{
Console.WriteLine("{0}", i);
}
}
}
Console.WriteLine("================");
if (x / 10000 < 100)
{
for (int i = 1000; i <= 9999; i++)
{
int a = i % 100;
int b = i / 100;
if (i == a * a + b * b)
{
Console.WriteLine("{0}", i);
}
}
for (int i = 10000; i <= x; i++)
{
int a = i % 100;
int b = i / 100;
int b2 = b % 100;
int c = b /100;
if (i==a*a*a+b2*b2*b2+c*c*c)
{
Console.WriteLine("{0}", i);
}
}
}
Console.ReadKey();
}
}
}
[2015][Quiz][Week03] Quiz02 - 40173027H
Quiz2_1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("103臺灣師範大學機電科技系物件導向程式設計_Quiz2");
int a, b, c;
for (int i = 1000; i < 1240; i++ )
{
b = i / 100;
c = i % 100;
/*Console.WriteLine("{0}", b);
Console.WriteLine("{0}", c);*/
if(i==((b * b)+(c * c)))
Console.WriteLine("{0}", i);
}
Console.ReadKey();
}
}
}
Quiz2_2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("103臺灣師範大學機電科技系物件導向程式設計_Quiz2_2");
int a, b, c, count=0;
int k;
for (int i = 1; i < 1000000; i++)
{
k = 0;
for (int j = 1; j < 1000000; j = j * 10)
{
k++;
if ((i / j) == 0)
{
count = (k - 1);
break;
}
}
a = i / 10000;
b = (i - a * 10000) / 100;
c = i % 100;
/*Console.WriteLine("{0}", count);
Console.WriteLine("{0}", a);
Console.WriteLine("{0}", b);
Console.WriteLine("{0}", c);*/
if (count == 1 || count == 2)
{
if (i == c)
Console.WriteLine("{0}", i);
}
else if (count == 3 || count == 4)
{
if (i == (b * b) + (c * c))
Console.WriteLine("{0}", i);
}
else if (count == 5 || count == 6)
{
if (i == (a * a * a) + (b * b * b) + (c * c * c))
Console.WriteLine("{0}", i);
}
}
Console.ReadKey();
}
}
}
[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();
}
}
}
訂閱:
意見 (Atom)