ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1149. Sinus Dances

C#
Posted by Faxfox 28 Nov 2019 11:48
using System;

class Test
{
    public static void Main()
    {
        String strB = "";
        String strA = "";

        int num = Convert.ToInt32(Console.ReadLine());
        int b = 1;

        for (int a = num; a > 0; a--)
        {
            strA = StrAMaker(a);

            strB = ')' + strA + '+' + b + strB;
            b++;
        }
        string s3 = new string('(', --num);
        strB = s3 + strB.TrimStart(')');
        Console.WriteLine(strB);
    }

    public static string StrAMaker (int a)
    {
        string s1 = new string(')', a);
        String s2 = "";

        for (int i = 1; i <= a; i++)
        {
            if (i % 2 == 0)
            {
                s2 = s2 + "sin(" + i + "+";
                if (i == a) s2 = s2.TrimEnd('+') + s1;
            }
            else
            {
                s2 = s2 + "sin(" + i + "-";
                if (i == a) s2 = s2.TrimEnd('-') + s1;
            }
        }

        return s2;
    }
}