Advertisement
darighteous1

ByteParty

Mar 15th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2.  
  3. class ByteParty
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.  
  9.         int[] numbers = new int[n];
  10.         //check for 1 line input!!!
  11.  
  12.         for (int i = 0; i < n; i++)
  13.         {
  14.             numbers[i] = int.Parse(Console.ReadLine());
  15.         }
  16.         string input = Console.ReadLine();
  17.         while (input != "party over")
  18.         {
  19.  
  20.             string[] command = input.Split(' ');
  21.             switch (command[0])
  22.             {
  23.                 case "-1":
  24.                     for (int i = 0; i < n; i++)
  25.                     {
  26.                         numbers[i] ^= (1 << int.Parse(command[1]));
  27.                     }
  28.                     break;
  29.                 case "0":
  30.                     for (int i = 0; i < n; i++)
  31.                     {
  32.                         numbers[i] &= ~(1 << int.Parse(command[1]));
  33.                     }
  34.                     break;
  35.                 case "1":
  36.                     for (int i = 0; i < n; i++)
  37.                     {
  38.                         numbers[i] |= (1 << int.Parse(command[1]));
  39.                     }
  40.                     break;
  41.             }
  42.  
  43.             input = Console.ReadLine();
  44.         }
  45.         for (int i = 0; i < n; i++)
  46.         {
  47.             Console.WriteLine(numbers[i]);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement