Just For Fun

using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.Collections;

namespace  TestFuns
ExpandedBlockStart.gifContractedBlock.gif
{
    
class Program
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{

ContractedSubBlock.gifExpandedSubBlockStart.gif        
Functions#region Functions
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
        
/// 数列
        
/// </summary>
        
/// <param name="n"></param>
        
/// <returns></returns>

ExpandedSubBlockStart.gifContractedSubBlock.gif        private static int numlist(int n){
            
if (n < 2)
                
return 1;
            
else
                
return numlist(n - 1+ numlist(n-2);
        }


ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
        
/// 显示1-50随机数,各不相同
        
/// </summary>

ExpandedSubBlockStart.gifContractedSubBlock.gif        private static void InsertRandomArr() 
            
int tmpNum=0;
            ArrayList newarr 
= new ArrayList();
            Random rd 
= new Random();
ExpandedSubBlockStart.gifContractedSubBlock.gif            
while (newarr.Count < 50{
                tmpNum 
= rd.Next(051);

                
if (!newarr.Contains(tmpNum))
                    newarr.Add(tmpNum);
            }


ExpandedSubBlockStart.gifContractedSubBlock.gif            
for (int i = 49; i > 0; i--{
                Console.Write(newarr[i].ToString()
+" ");
            }

        }



        
#endregion


ContractedSubBlock.gifExpandedSubBlockStart.gif        
DelegateDemo#region DelegateDemo
        
public class ShowMsgInfo
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
public delegate string msgOut(string str);
            
public msgOut ShowMsg;
        }


        
public static string ShowHTML(string str)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
return string.Format("<B>{0}</B>", str);
        }


        
public static string ShowTXT(string str)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
return str;
        }

        
#endregion


        
static void Main(string[] args)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
for (int i = 0; i < 10; i++)
                Console.WriteLine(numlist(i));

            InsertRandomArr();
            ShowMsgInfo sm 
= new ShowMsgInfo();
            sm.ShowMsg 
= new ShowMsgInfo.msgOut(ShowHTML);
            Console.WriteLine(sm.ShowMsg(
"Test"));
            sm.ShowMsg 
= new ShowMsgInfo.msgOut(ShowTXT);
            Console.WriteLine(sm.ShowMsg(
"Test2"));
            Console.Read();


        }

    }

}

转载于:https://www.cnblogs.com/netwenchao/archive/2009/11/13/1602721.html

猜你喜欢

转载自blog.csdn.net/weixin_33716941/article/details/93607831