标签:style blog http color io os ar for 数据
#include <stdio.h>
int main()
{
int num = 3;
int data = 0;
_asm
{
mov eax, num //num移动到eax
add eax, 4
mov data, eax
}
printf("%d", data); //结果输出7
return 0;
}
#include <stdio.h>
#define M 10.0
const int N = 10.0;
int main()
{
printf("%d\n", M); // 0
printf("%d\n", N); // 10
return 0;
}
printf("%d", 10.0); // 0
printf("%d\n",10.3); // -1717986918
printf("%f\n",10); // 0.000000
printf("%d\n%d\n", 10.0, 10); // 0 1076101120
#include <stdio.h>
int main()
{
int num = 100;
int *p1 = #
float *p2 = #
double *p3 = #
printf("%d\n", *p1);
printf("%f\n", *p2);
printf("%f\n", *p3);
return 0;
}
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main()
{
printf("INT_MAX = %d\n", INT_MAX);
printf("INT_MIN = %d\n", INT_MIN);
printf("LONG_MAX = %ld\n", LONG_MAX); //32位平台,long和int最大值一样
printf("LONG_MIN = %ld\n", LONG_MIN);
printf("LLONG_MAX = %lld\n", LLONG_MAX);
printf("LLONG_MIN = %lld\n", LLONG_MIN);
printf("FLT_MAX = %.100f\n", FLT_MAX);
printf("FLT_MIN = %.100f\n", FLT_MIN);
printf("DBL_MAX = %.500f\n", DBL_MAX);
printf("DBL_MIN = %.500f\n", DBL_MIN);
return 0;
}
long long moblie = 18611210283;//老师手机号
printf("%lld", moblie);
#include <stdio.h>
#include <limits.h>
int main()
{
unsigned int num = -1;
int data = 4294967295;
printf("%d\n", num); //-1
printf("%d\n", data); //-1
printf("%u\n", num); //4294967295
printf("%u\n", data); //4294967295
return 0;
}
char ch = -1;
int num = ch;
printf("%d\n",num);//-1
unsigned char ch = 3;
unsigned int num = ch;
printf("%d\n",num);//3
对于大小为32-bit的浮点数(32-bit为单精度,64-bit浮点数为双精度,80-bit为扩展精度浮点数),
1、其第31 bit为符号位,为0则表示正数,反之为-数,其读数值用s表示;
2、第30~23 bit为幂数,其读数值用e表示; 8位
3、第22~0 bit共23 bit作为系数,视为二进制纯小数,假定该小数的十进制值为x;
_declspec(dllexport) void go()
{
void *p1 = 0xae0000;
void *p2 = 0xaef000;
for (char *p = p1; p != p2; p++)//内存最小单位是字节
{
int *px = p;//设定步长为4
if (*px == 90)
*px = 99;
}
}
#include <stdio.h>
int main()
{
char ch1 = 6;
char ch2 = 5;
ch1 ^= ch2;
ch2 ^= ch1;
ch1 ^= ch2;
printf("%d\n", ch1); // 5
printf("%d\n", ch2); // 6
return 0;
}
char a = 240;
printf("%d\n", ~a); //15 位取反
printf("%d\n", !a); //0 逻辑取反
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int get_num(int num)
{
int index = 0;
while (num)
{
num &= num - 1;
index++;
}
return index;
}
int main()
{
int num;
scanf("%u", &num);
printf("%d\n", get_num(num));
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int get_num(int num)
{
int index = 0;
for (; num; num &= num - 1)
{
index++;
}
return index;
}
int main()
{
int num;
scanf("%u", &num);
printf("%d\n", get_num(num));
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int get_num(int num)
{
int index = 0;
AAAA:if (num)
{
num &= num - 1;
index++;
goto AAAA;
}
return index;
}
int main()
{
int num;
scanf("%u", &num);
printf("%d\n", get_num(num));
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int get_num(int num)
{
if (num == 0)
return 0;
return 1 + get_num(num & num - 1);
}
int main()
{
int num;
scanf("%u", &num);
printf("%d\n", get_num(num));
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int num;
scanf("%u", &num);
int data, i;
data = 1 << 31;
for (i = 1; i <= 32; i++)
{
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
if (i % 4 == 0) putchar(‘ ‘);
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int num;
scanf("%u", &num);
unsigned int data, i;
data = 1 << 31;
for (i = 1; i <= 32; i++)
{
printf("%c", num & data ? ‘1‘ : ‘0‘);
data >>= 1;
if (i % 4 == 0) putchar(‘ ‘);
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void buma(int num , int i)
{
if (i == 0)
return;
int data = 1 << 31;
if (i % 4 == 0) putchar(‘ ‘);
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
i--;
buma(num, i);
}
int main()
{
int num;
scanf("%u", &num);
buma(num,32);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int num;
scanf("%u", &num);
int data, i;
data = 1 << 31;
if (num < 0)
{
num = ~num + 1;
num = num | data; //保证符号位是负的
}
for (i = 1; i <= 32; i++)
{
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
if (i % 4 == 0) putchar(‘ ‘);
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void yuanma(int num, int i)
{
if (i == 0)
return;
int data = 1 << 31;
if (i % 4 == 0) putchar(‘ ‘);
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
i--;
yuanma(num, i);
}
int main()
{
int num;
scanf("%u", &num);
int data = 1 << 31;
if (num < 0)
{
num = ~num + 1;
num = num | data; //保证符号位是负的
}
yuanma(num, 32);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int num;
scanf("%u", &num);
int data, i;
data = 1 << 31;
if (num < 0)
{
num = num - 1;
num = num | data;
}
for (i = 1; i <= 32; i++)
{
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
if (i % 4 == 0) putchar(‘ ‘);
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void fanma(int num, int i)
{
if (i == 0)
return;
int data = 1 << 31;
if (i % 4 == 0) putchar(‘ ‘);
printf("%c", num & data ? ‘1‘ : ‘0‘);
num <<= 1;
i--;
fanma(num, i);
}
int main()
{
int num;
scanf("%u", &num);
int data = 1 << 31;
if (num < 0)
{
num = num - 1;
num = num | data;
}
fanma(num, 32);
return 0;
}
标签:style blog http color io os ar for 数据
原文地址:http://www.cnblogs.com/l6241425/p/3982217.html