www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Your 02.14

reply "FrankLike" <1150015857 qq.com> writes:
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?
Feb 14 2015
next sibling parent "Mengu" <mengukagan gmail.com> writes:
On Saturday, 14 February 2015 at 14:39:34 UTC, FrankLike wrote:
 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?
i'm not doing valentines day but i did propose my wife with a d program i wrote. :-)
Feb 14 2015
prev sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
i made a present for myself (as i really really love myself very much): a=20
minimalistic LISP interpreter (yeah, i need a *small* scripting language,=20
and memory/speed doesn't matter in this case, only source code size). and=20
i titled it MILF.=
Feb 14 2015
parent reply FG <home fgda.pl> writes:
On 2015-02-14 at 21:41, ketmar wrote:
 i made a present for myself (as i really really love myself very much): a
 minimalistic LISP interpreter (yeah, i need a *small* scripting language,
 and memory/speed doesn't matter in this case, only source code size). and
 i titled it MILF.
MILF as in Minimalistic Interpreter of Lisp Forms or Minimalistic Instant Lisp Fix? ;)
Feb 14 2015
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Sun, 15 Feb 2015 01:06:36 +0100, FG wrote:

 On 2015-02-14 at 21:41, ketmar wrote:
 i made a present for myself (as i really really love myself very much):
 a minimalistic LISP interpreter (yeah, i need a *small* scripting
 language,
 and memory/speed doesn't matter in this case, only source code size).
 and i titled it MILF.
=20 MILF as in Minimalistic Interpreter of Lisp Forms or Minimalistic Instant Lisp Fix? ;)
actually, it's "May I Leave Free?", as i really bored to recompile=20 project on each little customer fix (and 'cause my English sux). or "My=20 Incredible Language Foundation" when i need to describe to customers what=20 all that brackets means. ah, i don't know. ;-)=
Feb 14 2015
parent "zeomkean" <zeomkean gmail.com> writes:
The range version of startsWith (which I suspect is the most
commonly used one) is optimized beautifully. This leaves the
(rather trivial) single element one and the "one haystack, any of
these needles" one.



_______________
ahsan
Mar 18 2015