Advertisement
enevlogiev

LongSequenceFormatted

Jan 19th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2.  
  3. class PrintLongSequence
  4. {
  5.     static void Main()
  6.     {
  7.         Console.BufferWidth = 84;
  8.         Console.WindowWidth = Console.BufferWidth;
  9.         for (int i = 2; i <= 1001; i++)
  10.         {
  11.             if (i % 2 == 0)
  12.             {
  13.                 Console.Write("{0,4}, ", i);
  14.             }
  15.             else
  16.             {
  17.                 if (i == 1001)
  18.                 {
  19.                     Console.WriteLine("{0,4} ", -i);
  20.                 }
  21.                 else
  22.                 {
  23.                     Console.Write("{0,4}, ", -i);
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement