Advertisement
Venciity

[Jumpstart C#] loops demo - TOTO 6/49

Jan 24th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. class Toto
  4. {
  5.     static void Main()
  6.     {
  7.         int counter = 0;
  8.         for (int i1 = 1; i1 <= 44; i1++)
  9.             for (int i2 = i1 + 1; i2 <= 45; i2++)
  10.                 for (int i3 = i2 + 1; i3 <= 46; i3++)
  11.                     for (int i4 = i3 + 1; i4 <= 47; i4++)
  12.                         for (int i5 = i4 + 1; i5 <= 48; i5++)
  13.                             for (int i6 = i5 + 1; i6 <= 49; i6++)
  14.                             {
  15.                                 Console.WriteLine("{0} {1} {2} {3} {4} {5}", i1, i2, i3, i4, i5, i6);
  16.                                 // Try to comment the above row to speed up the program
  17.                                 counter++;
  18.                             }
  19.         Console.WriteLine("{0} combinations", counter);
  20.     }      
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement