September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,20 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void bin(int x, char *s)
|
||||
{
|
||||
char*_(int x){
|
||||
*(s = x ? _(x >> 1) : s) = (x & 1) + '0';
|
||||
return ++s;
|
||||
}
|
||||
*_(x) = 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char a[100];
|
||||
int i;
|
||||
for (i = 0; i <= 1984; i += 31)
|
||||
bin(i, a), printf("%4d: %s\n", i, a);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void IntToBitString(unsigned int number)
|
||||
{
|
||||
int num_bits = sizeof(unsigned int) * 8;
|
||||
|
||||
bool startPrinting = false;
|
||||
for (int bit_pos=num_bits-1; bit_pos >= 0; bit_pos--)
|
||||
{
|
||||
bool isBitSet = (number & (1<<bit_pos)) != 0;
|
||||
|
||||
if (!startPrinting && isBitSet)
|
||||
startPrinting = true;
|
||||
|
||||
if (startPrinting || bit_pos==0)
|
||||
printf("%s", isBitSet ? "1":"0");
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
IntToBitString(0);
|
||||
IntToBitString(5);
|
||||
IntToBitString(50);
|
||||
IntToBitString(9000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue