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.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- const int MAX = 8;
- const bool CENTERED = true;
- for(int i = 0; i <= MAX; i++)
- {
- string output = "";
- int sequence = sequencify(i, MAX);
- int result = resultify(sequence);
- for(int j = 0; j < result; j++)
- {
- output += "*";
- }
- if(CENTERED)
- {
- for(int j = sequence; j < MAX/2; j++)
- {
- output = " "+output;
- }
- }
- Console.WriteLine(output);
- }
- Console.WriteLine($"[index]\t-> [sequence]\t-> [1+sequence*2]");
- for(int i = 0; i < 9; i++)
- {
- Console.WriteLine($"{i}\t->\t {sequencify(i,MAX)}\t->\t {resultify(sequencify(i,MAX))}");
- }
- }
- public static int sequencify(int i, int period)
- {
- //0 1 2 3 4 5 6 7 0
- //0 1 2 3 4 3 2 1 0
- int half = period / 2;
- return i <= half ? i : period - i;
- }
- public static int resultify(int i)
- {
- //0 1 2 3 4 3 2 1 0
- //1 3 5 7 9 7 5 3 1
- return 1 + i * 2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement