Skip to content

Commit

Permalink
T39
Browse files Browse the repository at this point in the history
  • Loading branch information
Lelouch-Lirong committed Mar 7, 2023
1 parent 4785b09 commit 21af551
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions C_Programming/39.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
获取指定二进制位
将n左移k-1位,再与1做与操作
*/
#include<iostream>
using namespace std;
int getbit(int n, int k){
n = n>> (k-1);
n = n & 1;
return n;
}
int main()
{
int n, k;
cin>>n>>k;
cout<<getbit(n, k)<<endl;
return 0;
}
Binary file modified C_Programming/a.out
Binary file not shown.

0 comments on commit 21af551

Please sign in to comment.