惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
罗磊的独立博客
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
J
Java Code Geeks
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
N
News and Events Feed by Topic
腾讯CDC
P
Proofpoint News Feed
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
爱范儿
爱范儿
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
D
Docker
Y
Y Combinator Blog
博客园 - 聂微东
G
Google Developers Blog
S
Security @ Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
CERT Recently Published Vulnerability Notes
I
Intezer
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
博客园 - Franky
博客园 - 三生石上(FineUI控件)
W
WeLiveSecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
Scott Helme
Scott Helme
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LINUX DO - 最新话题
C
Cybersecurity and Infrastructure Security Agency CISA

博客园 - xumingming

SQL Server 的位运算 sql 的随机函数newID()和RAND() Linq To Xml (增,删,改,查) - xumingming sp_executesql的用法 Sql Server 存储过程分页 linq 存储过程返回多个结果集 Sql语句访问WEB 一些常用的类 MVC Controller与ActionResult的返回值 - xumingming - 博客园 IEnumerable_T_、IEnumerable、ICollection_T_、IList_T_、ObservableCollectin_T_和Collection_T_得关系 routes.MapRoute - xumingming - 博客园 JQuery与Ajax常用代码 MVC 小笔记 - xumingming - 博客园 GridView 的临时增删改查示例 GridView 72般绝技 C#代码中的事务 - xumingming - 博客园 VS2005中将GridView 中的数据导出至excel - xumingming - 博客园 触发器 删除数据库表中的信息(适用于被注入)
C# 长浏览
xumingming · 2011-02-11 · via 博客园 - xumingming

1)C# 求阶乘

View Code

递归方法:
using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(fun(
6).ToString());
Console.ReadKey();
}
public static double fun(int n)
{
if (n == 1)
return 1;
else
return fun(n - 1) * n;
}
}
}

非递归方法:

using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(fun(
6).ToString());
Console.ReadKey();
}
public static double fun(int n)
{
double S = 1;
for (int i = 0; i < n; i++)
{
S
*= (i+1);
}
return S;
}
}
}

2)C#题目,用递归算法算1.1.2.3.5.8.13....第30个是多少 ( 斐波那契)

View Code

public static int Add(int i)
{
if (i <= 0)
{
return 0;
}
else if (i > 0 && i <= 2)
{
return 1;
}
else
{
return Add(i - 1) + Add(i - 2);

}
}

3) C# 基础 

View Code

C#基础
ArrayList
ArrayList al;
al
=new ArrayList();
string s = Console.ReadLine();
while(s !="q")
{ al.Add(s);
s
= Console.ReadLine();
}
for(int i=0;i<al.Count;i++)
Console.WriteLine(al[i].ToString());
从键盘输入一个数组,并求最大
int[] a;
Console.WriteLine(
"Pls input len:");
int len = Convert.ToInt32(Console.ReadLine());
a
= new int[len];
Console.WriteLine(
"Pls input array");
for(int i=0;i<len;i++)
{ a[i]
=Convert.ToInt32(Console.ReadLine()); }
for(int j=0;j<a.Length;j++)
Console.WriteLine(a[j]);
for(int k=0;k<a.Length;k++)
{
if(a[0]<a[k])
a[
0]=a[k];
} Console.WriteLine(a[
0]);
递归
int fac (int n)
{
if(n==0) return 1;
return n*fac(n-1);
}
斐波那契数列第n项
int fib (int n)
{
if(n==1) return 1;
if(n==2) return 1;
return fib(n-1)+fib(n-2);
}
递归求1加到100
public int Fac(int n)
{
if(n==1) return 1;
return

……………………………………
;
}

static void Main()
{ math f
=new math();
int s=f.Fac(100);
Console.WriteLine(s);
}
求前24项斐波那契序列数
static int fib(int n)
{
if(n==1) return 1;
if(n==2) return 1;
return fib(n-1)+fib(n-2);
}
static void Main(string[] args)
{
int t=0;
for(int i=1;i<25;i++)
{ t
=fib(i);
Console.WriteLine(t);
} }
汉诺塔
static void Hanoi(string X, string Y,string Z,int n)
{
if(n==1)
{ Console.WriteLine(X
+ "-->" +Z);
return;
}
Hanoi (X,Z,Y,n
-1);
Console.WriteLine(X
+"-->"+Z);
Hanoi (Y,X,Z,n
-1);
}
static void Main(string[] args)
{ Hanoi(
"A","B","C",5); }
3位的水仙花数
for(int i=100;i<1000;i++)
{
int a=i/100; int c=i%10; int b=((i-c)/10)%10;
if(i==a*a*a+b*b*b+c*c*c)
Console.WriteLine(i);
}
StringBuilder
class A
{
static void Main()
{ StringBuilder a
=new StringBuilder();
a.Append (
"asa");
a.Append (
"www");
string s=a.ToString();
Console.WriteLine(s);
}
} 结果:asawww
singleton设计模式
class A
{
private int v;
A(
int x)
{ v
=x; }
public int V
{
get{return v;} }
static A c=null;
public static A fun(int n)
{
if(c==null)
c
=new A(n);
return c;
}
}
class B
{
static void Main(string[] args)
{ A c
=A.fun(2);
Console.WriteLine(c.V);
c
=A.fun(8);
Console.WriteLine(c.V);
}
} 结果:
2,2