求大家做编程题啊!做出悬赏!

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:37:12
求出所有这样的四位数,其前两位数的平方与后两位数字的平方和等于该数本身
用VF的形式写出,谢!

我用c实现吧
main()
{
int i,j,k,m;
for(i=1;i<10;i++)
for(j=0;j<10;j++)
for(k=0;k<10;k++)
for(m=0;m<10;m++)
if((i*10+j)*(i*10+j)+(10*k+m)*(10*k+m)==1000*i+100*j+10*k+m)
printf("%d",(1000*i+100*j+10*k+m));
}
我求出来的答案为:1233,8833

C#来实现
private void Page_Load(object sender, System.EventArgs e)
{
int a,b,c;
for(c = 1000;c < 10000;c++)
{
a = c / 100;
b = c % 100;
if(c==a*a+b*b)
{
Response.Write(c+",");
}
}
}

我用C++做给你
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
for(c=1000;c<10000;c++)
{
a=c/100;
b=c%100;
if(c==a*a+b*b){
cout<<c<<endl;
}
}
return 0;
}
答案是1233,8833

我用c#给你做:
using System;
using System.Collections.Generic;
using System.Tex