Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace lesson10
- {
- /*
- * -Цикл выводит числа в следующем порядке:
- 1 +1
- 2 -1
- 1 +2
- 3 +1
- 4 -1
- 3 +2
- 5 +1
- 6 -1
- 5 +2
- 7
- Или так:
- 1 +1
- 2 -1
- 1 +1
- 2 +1
- 3 -1
- 2 +1
- 3 +1
- 4 -1
- 3 +1
- 4
- 5
- 4
- 5
- 6
- * */
- class Program
- {
- static void Main(string[] args)
- {
- int number = 1;
- int directionChangeStep = 1;
- int transitionStep = 1;
- for(int i = 0; i < 20; i++)
- {
- Console.WriteLine(number);
- number += directionChangeStep * (int)Math.Pow(-1, i % 3) + transitionStep * ((int)Math.Pow(-1, i % 3) + (int)Math.Pow(-1, (i + 1) % 3)) / 2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement