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 ByteParty
- {
- class ByteParty
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- int[] n = new int[count];
- for (int i = 0; i < n.Length; i++)
- {
- n[i] = int.Parse(Console.ReadLine());
- }
- //n = n ^ (1 << pos); // обръща бит-а на дадена позиция (0 -> 1 или 1 -> 0)
- //n = n & ~(1 << pos); // прави бит-а 0-ла
- //n = n | (1 << pos); // прави бит-а 1-ца
- while (true)
- {
- string[] inputcommand = Console.ReadLine().Split();
- if (inputcommand[0] == "party")
- {
- break;
- }
- string command = inputcommand[0];
- int pos = int.Parse(inputcommand[1]);
- for (int i = 0; i < n.Length; i++)
- {
- if (command == "-1")
- {
- n[i] ^= 1 << pos;
- }
- if (command == "0")
- {
- n[i] &= (-1 << pos);
- }
- if (command == "1")
- {
- n[i] |= 1 << pos;
- }
- }
- }
- for (int i = 0; i < n.Length; i++)
- {
- Console.WriteLine(n[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment