NMDanny

basket arrays

Jan 2nd, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Basket  // דניאל קרבל - י'5
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int[] Player = new int[5];
  13.             int[] ScoreType = new int[3];
  14.  
  15.             int Max1 = -1;
  16.             int end = 0, teamsum = 0;
  17.  
  18.             int[] Best = new int[5];
  19.             while (end != 1)
  20.             {
  21.                 Console.WriteLine("Type the player's number(1-5) or 0 to finish.");
  22.                 int PlayerNum = int.Parse(Console.ReadLine());
  23.                 if (PlayerNum == 0)
  24.                 {
  25.                     end = 1;
  26.                 }
  27.                 else
  28.                 {
  29.                     Console.WriteLine("Type the score type(0-3)");
  30.                     int Score = int.Parse(Console.ReadLine());
  31.                     Player[PlayerNum - 1] += Score;
  32.                     teamsum+= Score;
  33.  
  34.                     if (Player[PlayerNum - 1] >= Max1)
  35.                     {
  36.                         Max1=Player[PlayerNum-1];
  37.                     }
  38.  
  39.                     ScoreType[Score-1] += 1;
  40.                 }
  41.             }
  42.             for (int i = 0; i < Player.Length; ++i)
  43.             {
  44.                 if (Player[i] == Max1)
  45.                 {
  46.                     Best[i] = 1;
  47.                 }
  48.             }
  49.             Console.WriteLine("The following player numbers have scored the maximum points which is {0}", Max1);
  50.             for (int i = 0; i < Player.Length; ++i)
  51.             {
  52.                 if (Best[i] == 1)
  53.                 {
  54.                     Console.Write(" {0}", i+1);
  55.                 }
  56.             }
  57.             Console.WriteLine();
  58.             Console.WriteLine("The team scored a total of " + teamsum + " points.");
  59.             int Max = -1,CommonShot=-1;
  60.             for (int i = 0; i < ScoreType.Length; ++i)
  61.             {
  62.                 if (ScoreType[i] > Max)
  63.                 {
  64.                     Max = ScoreType[i];
  65.                     CommonShot = i;
  66.  
  67.                 }
  68.             }
  69.             Console.WriteLine("The most common shot is a {0} point shot", CommonShot+1);
  70.             int[] None = new int[5];
  71.             Console.WriteLine("The following player numbers haven't scored any points:");
  72.             for (int i = 0; i < Player.Length; ++i)
  73.             {
  74.                 if (Player[i] == 0)
  75.                 {
  76.                     Console.Write(" {0} ", i+1);
  77.                 }
  78.             }
  79.             Console.WriteLine();
  80.  
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment