Advertisement
rosenrusev

Problem 9 - PrintASequence

Mar 11th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace PrintASequence
  7. {
  8. class PrintASequence
  9. {
  10. static void Main()
  11. {
  12. for (short i = 2; i < 12; i++)
  13. {
  14. if (i % 2 == 0)
  15. {
  16. Console.Write(i + ","); // четни числа
  17. }
  18. else
  19. {
  20. Console.Write((-i) + ","); // нечетни числа
  21. }
  22. }
  23. }
  24. }
  25. }
  26. // Console Output: 2,-3,4,-5,6,-7,8,-9,10,-11,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement