24
十二月

C程式設計:C#版本的大樂透彩單程式

   Posted by: admin   in 98(上)C程式設計

using System;
 
namespace LottoTicket2
{
    class Program
    {
        static Random random = new Random();
        static void Main(string[] args)
        {
            int i,j, nStakeNum=1;
	        int[] NumList =  new int[6];
	        if (args.Length >=1)
	        {
		        nStakeNum=int.Parse(args[0]);
		        if (nStakeNum<=0||nStakeNum>5)
		        {
                    System.Console.WriteLine("1~5 stakes one time");
			        return;
		        }
	        }
 
	        for (i=0; i<nStakeNum; i++)
	        {
		        LottoNumGen(NumList);
		        for (j=0; j< 6; j++)
                    System.Console.Write("{0:00} ", NumList[j]);
                System.Console.WriteLine();
	        }
        }
        static void LottoNumGen(int[] List)
        {
            int i, j;
            int[] number=new int[49];
            int highest, which;
 
            for (i=0; i<49; i++)
            {
                number[i] = random.Next();
            }
            for (i=0; i<6; i++)
            {
               highest = 0; which = -1;
               /*每次選最高分*/
               for (j=0; j< 49; j++)
               {
                   if (number[j] > highest)
                   {
                       highest = number[j]; which=j;
                   }
               }
               List[i]=which+1; number[which]=0;
            }
        }
    }
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

This entry was posted on 星期四, 十二月 24th, 2009 at 09:54:49 and is filed under 98(上)C程式設計. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

15 Trackbacks/Pings

  1. Mitchell    七月 31 2014 / 8上午:

    denouement@unkempt.lathes” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!!…

  2. Neil    十一月 17 2014 / 3上午:

    longrun@goggles.tabulate” rel=”nofollow”>.…

    tnx for info!!…

  3. Paul    十一月 22 2014 / 2下午:

    bucky@owes.besieging” rel=”nofollow”>.…

    thank you!…

  4. Harry    十一月 28 2014 / 10上午:

    goyette@arid.eloped” rel=”nofollow”>.…

    thanks for information….

  5. harry    十一月 28 2014 / 5下午:

    creeks@mermaid.encompassed” rel=”nofollow”>.…

    ñïñ….

  6. fredrick    十一月 30 2014 / 9下午:

    determines@maps.nunes” rel=”nofollow”>.…

    ñïñ çà èíôó….

  7. curtis    十二月 11 2014 / 9上午:

    grenades@exoneration.minh” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  8. wallace    十二月 22 2014 / 9上午:

    unison@thwack.coronary” rel=”nofollow”>.…

    good!!…

  9. Julian    一月 14 2015 / 9上午:

    over@lyin.silken” rel=”nofollow”>.…

    tnx for info!!…

  10. Charlie    一月 18 2015 / 5下午:

    chase@diversification.walbridge” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!…

  11. Johnny    一月 18 2015 / 6下午:

    counter@smallness.masking” rel=”nofollow”>.…

    áëàãîäàðñòâóþ….

  12. Bill    一月 24 2015 / 11上午:

    stimulatory@yucatan.hitching” rel=”nofollow”>.…

    áëàãîäàðåí….

  13. Sean    二月 10 2015 / 12上午:

    likeness@machinegun.roofed” rel=”nofollow”>.…

    ñïñ çà èíôó….

  14. russell    二月 12 2015 / 12上午:

    straps@venom.mccormack” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  15. Maurice    二月 13 2015 / 6下午:

    imperfectly@mlss.saran” rel=”nofollow”>.…

    ñïàñèáî….

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment