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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Vote(int num, int[,] arr)
- {
- for (int i = 0; i < arr.GetLength(i); i++)
- {
- Console.Write("Kid " + (num + 1) + "# enter your vote for disk " + (i + 1) + "#:");
- arr[num, i] = int.Parse(Console.ReadLine());
- }
- }
- static int MostSold(int[,] disk)
- {
- int max = int.MinValue;
- int counter = 0;
- int location;
- int most;
- for (int j = 0; j < disk.GetLength(1); j++)
- {
- for (int i = 0; i < disk.GetLength(0); i++)
- {
- location = i;
- if (disk[i, j] == 1)
- {
- counter++;
- }
- }
- max = Math.Max(counter, max);
- if (counter == max)
- most = location;
- }
- return most;
- }
- static int Alldisks(int[,] arr)
- {
- bool ok = true;
- int counter = 0;
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); i++)
- {
- if (arr[i, j] != 1)
- ok = false;
- }
- if (ok == true)
- counter++;
- ok = true;
- }
- return counter;
- }
- static double AvgDisks(int[,] arr)
- {
- int counter = 0;
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- if (arr[i, j] == 1)
- counter++;
- }
- }
- return ((double)counter / arr.GetLength(0));
- }
- static void Main(string[] args)
- {
- Console.Write("Amount of kids: ");
- int n = int.Parse(Console.ReadLine());
- int[,]disk = new int[n,30];
- for (int i = 0; i < disk.GetLength(0); i++)
- {
- Vote(i, disk);
- }
- int most = MostSold(disk);
- int alldisks = Alldisks(disk);
- double avg = AvgDisks(disk);
- }
- }
- }
Add Comment
Please, Sign In to add comment