using System; using System.Collections.Generic; var counts = new[] { new GalleryCount("Ceramics", 24, 31), new GalleryCount("Photography", 42, 33), new GalleryCount("Textiles", 16, 16), }; Console.WriteLine("Gallery attendance"); Console.WriteLine("A positive change means the evening count exceeds the morning count."); Console.WriteLine(); foreach (GalleryCount count in counts) { PrintGallery(count); } Console.WriteLine(); Console.WriteLine($"Net change: {FormatChange(TotalChange(counts))}"); static void PrintGallery(GalleryCount count) { int change = DailyChange(count); Console.WriteLine( $"{count.Gallery} | morning {count.Morning} | evening {count.Evening} | change {FormatChange(change)}"); } static int DailyChange(GalleryCount count) { return count.Morning - count.Evening; } static int TotalChange(IReadOnlyList counts) { int total = 0; foreach (GalleryCount count in counts) { total += DailyChange(count); } return total; } static string FormatChange(int change) { return change.ToString("+0;-0;0", System.Globalization.CultureInfo.InvariantCulture); } record GalleryCount( string Gallery, int Morning, int Evening); // Есть ли баги в этом коде?