有一个四位的车牌,甲看说前两位相同,已说后两位相同,且不与前两位相同,丙,是个数学家,他说这个车牌正是一个整数的平方,请用c#代码求出这个车牌。谢谢
解决方案 »
- 怎么向数据库里插入图片(Image类型)
- C#的控件问题
- 图片问题
- 请问c++中指向结构的指针在c#中怎么表示啊?
- 帮我写一个取质数的小程序
- 两个项目,单独运行时无错误,把其中一个添加到另外一个项目里运行却出错了
- SqlDataReader对像取记录总数和取指定的 记录
- 怎么从XML文件中取数据!在线等
- 精通asp,asp.net三年工作经验,现在准备考研,但是需要找份兼职糊口,每月2000左右就成,各位给点意见
- 为什么定义好的dataset无法加载
- C#关于Socket的问题 异常为:The operation is not allowed on non-connected sockets.
- 使用bindingSource 可以对数据进行修改的取消吗?
for (int i = 1; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
t = i * 1000 + i * 100 + j * 10 + j;
if (Math.Sqrt(t).ToString().IndexOf(".") < 0)
{
Console.WriteLine(t.ToString() +" "+Math.Sqrt(t).ToString() +"\r\n");
}
}
}结果是-->>> 7744 88
for (int j = 0; j < 10; j++)
{
if (i == j) continue;
int d12 = i * 10 + i, d34 = j * 10 + j, d1234 = d12 * 100 + d34;
if (Math.Truncate(Math.Sqrt(d1234)) - Math.Sqrt(d1234) < 0.01)
return d1234;
}
for(int i=0;i<9;i++)
{
for (int j=0;j<9;j++)
{
if(i!=j)
{
sum=j+10*j+100*i+1000i;
resutl = System.Math.Sqrt(sum);
if(checkint(resutl));
{
//保存resutl待输出;
}
}
}
}//判断整数是网上找的,你可以试下
checkint(double a)
{
string num=a.ToString();
public const string ZZValidInt2=@"^-?\d+$";
return Regex.IsMatch(num,ZZValidInt2);
}不知道是不是满足你的要求,方法有点笨
using System.Text.RegularExpressions;namespace test3
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("please wait ……");
int m=0;
for (int num=1;num<10000;num++)
{
for ( int i=1; i< 10 ; i++ )
{
for ( int j=1; j<10 ; j++ ) {
if (j!=i && IsValidString((Math.Sqrt(num)).ToString(),@"^-?\d+$") && 110*i + 11*j == num )
{ m++;
Console.WriteLine("找到第{0}个数:{1}",m,num);
}
}
}
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
private static bool IsValidString(string str,string ZZValidItem)
{
return Regex.IsMatch(str,ZZValidItem);
}
}
for (int i = 32; i < 100; i++)
{
int num = i * i;
int n1 = num / 1000;
int n2 = (num % 1000) / 100;
int n3 = (num % 100) / 10;
int n4 = num % 10;
if (n1 == n2 && n3 == n4 && n1 != n3)
{
Console.WriteLine(num);
}
}