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;
- using System.Threading.Tasks;
- namespace ConsoleApplication23
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[,] names = { { "A", "A", "S", "D" },
- { "B", "D", "A", "B"},
- {"D", "S", "D", "A" },
- {"S", "B", "B", "S" } };
- int[] votes = { 44, 32, 27, 37 };
- Console.WriteLine("Таблица с голосами:");
- for (int i = 0; i < names.GetLength(0); i++)
- {
- for (int j = 0; j < names.GetLength(1); j++)
- {
- Console.Write(names[i, j] + " ");
- }
- Console.WriteLine("");
- }
- for (int i = 0; i < votes.Length; i++)
- {
- Console.Write(votes[i] + " ");
- }
- Console.WriteLine();
- Console.WriteLine("-----------");
- int[] f = new int[4];
- int bal = 3;
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 4; j++)
- {
- if (names[i,j] == "A")
- {
- f[0]+= votes[j] * bal;
- }
- else if (names[i, j] == "B")
- {
- f[1]+= votes[j] * bal;
- }
- else if (names[i, j] == "D")
- {
- f[2] += votes[j] * bal;
- }
- else if (names[i, j] == "S")
- {
- f[3] += votes[j] * bal;
- }
- }
- bal--;
- }
- Console.WriteLine("F(A) = " + f[0]);
- Console.WriteLine("F(B) = " + f[1]);
- Console.WriteLine("F(D) = " + f[2]);
- Console.WriteLine("F(S) = " + f[3]);
- Array.Sort(f);
- Array.Reverse(f);
- Console.WriteLine("Наибольшее количество голосов: " + f[0]);
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement