|
|
вернуться в форумC# Послано Faxfox 28 ноя 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; } } |
|
|