asp.net(c#) 水仙花数
水仙花数:一个三位整数各位数字的立方和等于该数本身就称该数为水仙花数,水仙花数共有4个,分别为:153、370、371、407( 例如:1^3 + 5^3 + 3^3 = 153 )。我写的代码如下,你有其他的实现代码也可以发表评论。
int i, m,n,k;
for (i = 100; i < 1000; i++)
{
//取得百位数
m = i / 100;
//取得十位数,这里也可以用n = (i%100)/10;
n = i/10%10;
//取得个位数
k = i % 10;
//打印输出水仙花数
if (m * m * m + n * n * n + k * k * k == i)
Response.Write(i + "<br />");
}
相关文档:
//获取包含清单的已加载文件的路径或 UNC 位置。
public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location;
//result: X:\xxx\xxx\xxx.dll (.dll文件所在的目录+.dll文件名)
//获取当前进程的完整路径,包含文件名(进程名)。
string str = this.GetType ( ).Assembly.Location;
//result ......
c# 中 is和as 操作符是用来进行强制类型转换的
is : 检查一个对象是否兼容于其他指定的类型,并返回一个Bool值,永远不会抛出异常
object o = new object();
if (o is Label)
{
Label lb = (Label)o;
Response.Write("类型转换成功");
}
else
{
Response.Write(" ......
/**************************************************************************************************
* 作者wenwenhua
*
/* Program : A Simple Screen Saver
* File Name : ScreenSaver.cs
* Author : Tran Khanh Hien
......
asp.net允许上传的文件的最大为4M
如果想要传更大的需要更改web.config文件
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</ststem.web> ......