Created
February 28, 2018 18:59
-
-
Save gallirohik/6d8b656254ff30159f7b23f3fee1161c to your computer and use it in GitHub Desktop.
who is alive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int who_alive(int n,int k) | |
{ | |
unsigned int mask=0x01,i=1,alived; | |
mask=mask<<7; | |
n=n<<k; | |
while((n&mask)==0) | |
{ | |
mask=mask>>1; | |
i++; | |
if(i==7)break; | |
} | |
n=n&(mask-1); | |
alived=n|1; | |
printf("%d",alived); | |
return 0; | |
} | |
int main() | |
{ | |
int n,k; | |
scanf("%d%d",&n,&k); | |
who_alive(n,k); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment