vstoyanov

Оператори и Изрази 12

May 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import org.omg.CORBA.MARSHAL;
  2. import org.omg.Messaging.SYNC_WITH_TRANSPORT;
  3.  
  4. import java.lang.reflect.Array;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner scanner=new Scanner (System.in);
  11.  
  12.         int n=Integer.parseInt(scanner.nextLine());
  13.                       int p=Integer.parseInt(scanner.nextLine());      
  14.         int v=Integer.parseInt(scanner.nextLine());
  15.  
  16.  
  17.  
  18.  
  19.  
  20.         if(v==0){
  21.  
  22.           n=(n&~(1<<p));
  23.         }else {
  24.  
  25.            n=(n|(1<<p));
  26.         }
  27.  
  28.         System.out.println(n);
  29.        
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment