fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var mydata = new IEnumerable<int>[] { Enumerable.Range(2, 3), Enumerable.Range(5, 5), Enumerable.Range(7, 6), Enumerable.Range(3, 2) };
  14. //The idea is I require 6 rows. The IEnumerable is a column
  15. //The first row will contain the first value of every IEnumerable. Second row will hold second value of each IEnumerable and etc
  16. //If there isn't enough values in the column put -1 as a placeholder
  17. var temp = new List<int>[6];
  18. for (int i = 0; i < 6; ++i)
  19. temp[i] = new List<int>();
  20. foreach (var v in mydata)
  21. {
  22. var len = v.Count();
  23. int i;
  24. for (i = 0; i < 6&&i<len; ++i)
  25. {
  26. temp[i].Add(v.ElementAt(i));
  27. }
  28. for (; i < 6; ++i)
  29. temp[i].Add(-1);
  30. }
  31. foreach (var outer in temp)
  32. {
  33. foreach (var inner in outer)
  34. {
  35. Console.WriteLine(inner);
  36. }
  37. Console.WriteLine("---");
  38. }
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 0.03s 33920KB
stdin
Standard input is empty
stdout
2
5
7
3
---
3
6
8
4
---
4
7
9
-1
---
-1
8
10
-1
---
-1
9
11
-1
---
-1
-1
12
-1
---