Your 02.14

FrankLike via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 14 06:39:33 PST 2015


2015-2-14,I build a small program for wife:

module for214;

import std.stdio;
import std.random;

extern(C) int setlocale(int, char*);

static this()
{
	import core.stdc.wchar_;
    fwide(core.stdc.stdio.stdout, 1);
    setlocale(0, cast(char*)"china");
}


void main()
{
     int i;
    while (1)
    {

     int[] a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8,9];
      if(i ==0)
      {
      foreach(p;a)
     	write(p,",");

	   writeln("\n共有10个奖,从现在开始闭上眼睛,过10秒钟,然后随意输个数,开始抽奖:");
     }
     else
     {
     	break;//若删除,可以连续中3次。
     }
      char[] b;
      readln(b);

      if(b[0] =='q') break;

      string[] s 
=["祝节日快乐","中奖300元","老公洗你的衣服","一起看电影(任你选)","一起吃大餐","明天下午老公带孩","老公给你讲笑话","网上看大片,老公带孩","在一起","给孩讲故事"];
	
	foreach (e; randomCover(a))
	{
         writeln("中的是:",s[e]);
         if(e != 0)
         break;
         else
         {
         	 writeln("不满意? 再来一次:");
         	 continue;
         }
     }
     i++;
     if(i >2)
     {
     	 writeln("恭喜老婆!");
     	 break;
     }
   }
}

-------------------------end-----------------
How about you?


More information about the Digitalmars-d mailing list