Comment detail

変形Fizz-Buzz問題 (Nested Flatten)
無限にyield。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;

class Program {
    static IEnumerable<string> FizzBuzz() {
        while (true) {
            yield return "hoge";
            yield return "hoge";
            yield return "Fizz";
            yield return "hoge";
            yield return "Buzz";
            yield return "Fizz";
            yield return "hoge";
            yield return "hoge";
            yield return "Fizz";
            yield return "Buzz";
            yield return "hoge";
            yield return "Fizz";
            yield return "hoge";
            yield return "hoge";
            yield return "FizzBuzz";
        }
    } 
    static void Main(string[] args) {
        int i = 0;
        foreach (string s in FizzBuzz()) {
            if (++i > 20) break;
            Console.WriteLine("{0, 2}:{1}", i, s);
        }
    }
}

Index

Feed

Other

Link

Pathtraq

loading...