Programmatically generate decision table in C#?

后端 未结 5 1996
旧时难觅i
旧时难觅i 2021-01-06 23:47

I have this situation that I need to let users define decisions based on the number of given conditions. For example my program needs to automatically generate a matrix as b

5条回答
  •  孤城傲影
    2021-01-06 23:51

    Outputting the matrix is rather trivial:

    int conditions = 3;
    for (int c = 0; c < conditions; c++) {
        Console.WriteLine(
           "Condition {0} : {1}",
           (char)('A' + c),
           new String(
              Enumerable.Range(0, (1 << conditions))
              .Select(n => "TF"[(n >> c) & 1])
              .ToArray()
           )
        );
    }
    

    So, what do you want to do with it?

提交回复
热议问题