string[] CustomSort(string[] A) //Bad way of doing it. { List <Mystr> myList = new List <Mystr>(); for (int i = 0; i < A.Length; i++) { Mystr m = new Mystr(A[i], A[i].Length); myList.Add(m); } myList.Sort(); string[] B = new string[A.Length]; for (int i = 0; i < A.Length; i++) { B[i] = myList[i].s; } return(B); }
public string GetStr() { // Console.WriteLine(Mystr + " BBBBBBBBBb "); string Str = ">>Количество строк в тексте: " + n + "\n"; int j = 0, k = 1; for (int i = 0; i < Mystr.Length; i++) { if (Mystr[i] == '\n') { Str += Mystr.Substring(j, (i - j + 1)); j = i + 1; Str += ">>Количество слов в тексте: " + k + '\n'; k = 1; } else if ((Mystr[i] == ' ') && (Mystr[i + 1] != ' ')) { k++; } } Console.WriteLine(Str); return(Str); }