Advertisement
Konark

Untitled

Dec 1st, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication23
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[,] names = { { "A", "A", "S", "D" },
  14.                 { "B", "D", "A", "B"},
  15.                 {"D", "S", "D", "A" },
  16.                 {"S", "B", "B", "S" } };
  17.             int[] votes = { 44, 32, 27, 37 };
  18.             Console.WriteLine("Таблица с голосами:");
  19.             for (int i = 0; i < names.GetLength(0); i++)
  20.             {
  21.                 for (int j = 0; j < names.GetLength(1); j++)
  22.                 {
  23.                     Console.Write(names[i, j] + "  ");
  24.                 }
  25.                 Console.WriteLine("");
  26.             }
  27.             for (int i = 0; i < votes.Length; i++)
  28.             {
  29.                 Console.Write(votes[i] + " ");
  30.             }
  31.             Console.WriteLine();
  32.             Console.WriteLine("-----------");
  33.             int[] f = new int[4];
  34.             int bal = 3;
  35.             for (int i = 0; i < 4; i++)
  36.             {
  37.                 for (int j = 0; j < 4; j++)
  38.                 {
  39.                     if (names[i,j] == "A")
  40.                     {
  41.                         f[0]+= votes[j] * bal;
  42.                     }
  43.                     else if (names[i, j] == "B")
  44.                     {
  45.                         f[1]+= votes[j] * bal;
  46.                     }
  47.                     else if (names[i, j] == "D")
  48.                     {
  49.                         f[2] += votes[j] * bal;
  50.                     }
  51.                     else if (names[i, j] == "S")
  52.                     {
  53.                         f[3] += votes[j] * bal;
  54.                     }
  55.                 }
  56.                 bal--;
  57.             }
  58.             Console.WriteLine("F(A) = " + f[0]);
  59.             Console.WriteLine("F(B) = " + f[1]);
  60.             Console.WriteLine("F(D) = " + f[2]);
  61.             Console.WriteLine("F(S) = " + f[3]);
  62.             Array.Sort(f);
  63.             Array.Reverse(f);
  64.             Console.WriteLine("Наибольшее количество голосов: " + f[0]);
  65.             Console.Read();
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement