Ai
1 Star 0 Fork 0

东华万里/Blog code

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
12.13.c 4.69 KB
一键复制 编辑 原始数据 按行查看 历史
#define _CRT_SECURE_NO_WARNINGS
////
////#include <stdio.h>
////int main()
////{
//// int a = 10;
//// int b = (a << 1);
//// printf("%d\n", b);
////
////
//// return 0;
////}
//
//
//#include <stdio.h>
//int main()
//{
// int a = -10;
// int b = (a >> 1);
// printf("%d\n", b);
//
//
// return 0;
//}
//#include <stdio.h>
//int main() {
// // 有符号数(int):算术右移
// int a = -10;
// printf("有符号数-10右移1位:%d\n", a >> 1); // 输出-5(算术右移)
//
// // 无符号数(unsigned int):逻辑右移
// unsigned int b = -10; // 无符号数存储为补码:4294967286
// printf("无符号数-10右移1位:%u\n", b >> 1); // 输出2147483643(逻辑右移)
// return 0;
//}
//#include <stdio.h>
//int main()
//{
// int a = 0;
// int b = ~a;
// printf("%d\n", b);
//
//
// return 0;
//}
//
//#include <stdio.h>
//int main()
//{
// int a = 5;
// int b = ~a;
// printf("%d\n", b);
//
//
// return 0;
//}
//#include <stdio.h>
//int main()
//{
// int num = 45; // 二进制:00101101(8位简化)
// int n = 3; // 要清0的位:第3位(从0计数)
// int mask = ~(1 << n); // 掩码:~00001000 = 11110111
// int res = num & mask; // 00101101 & 11110111 = 00100101(37)
// printf("清0第%d位后:%d\n", n, res); // 输出:清0第3位后:37
// return 0;
////}
//
//
//#include <stdio.h>
//int main()
//{
// int a = -3;
// int b = 5;
//
// int c = a&b;
// printf("%d\n", c);
//
//
// return 0;
//}
//#include <stdio.h>
//int main()
//{
// int num = 17;
// if (num & 1)
// {
// printf("%d 是奇数\n", num); // 输出17是奇数
// }
// else
// {
// printf("%d 是偶数\n", num);
// }
// return 0;
//}
//
//
//
//
//#include <stdio.h>
//int main()
//{
// int a = 13;
// int b = (1<<4);
//
// int c = a|b;
// printf("%d\n", c);
//
//
// return 0;
//}
//
//#include <stdio.h>
//int main()
//{
// int num = 45; // 00101101
// int mask = 1 << 6; // 掩码:01000000(第6位为1)
// int res = num | mask; // 00101101 | 01000000 = 01101101(109)
// printf("置1第6位后:%d\n", res); // 输出109
// return 0;
//}
//#include <stdio.h>
//int main()
//{
// int a = 10, b = 20;
// printf("交换前:a=%d, b=%d\n", a, b); // 10,20
//
// a = a ^ b; // a = 10^20
// b = a ^ b; // b = (10^20)^20 = 10^(20^20)=10^0=10
// a = a ^ b; // a = (10^20)^10 = 20^(10^10)=20^0=20
//
// printf("交换后:a=%d, b=%d\n", a, b); // 20,10
// return 0;
//}
//
//
//#include <stdio.h>
//int main()
//{
// int arr[] = { 2,3,2,4,4,5,5 };
// int len = sizeof(arr) / sizeof(arr[0]);
// int res = 0;
// for (int i = 0; i < len; i++) {
// res ^= arr[i]; // 0^2^3^2^4^4^5^5 = 3
// }
//// printf("唯一奇数次的数:%d\n", res); // 输出3
//// return 0;
////}
//
//
//
//#include <stdio.h>
//
//// 声明struct Stu类型的同时,直接定义变量s1、s2(全局变量)
//struct Stu
//{
// char name[20]; // 名字
// int age; // 年龄
//} s1, s2;
//#include <stdio.h>
//
//// 1. 先声明struct Stu类型(仅模板,无变量)
//struct Stu
//{
// char name[20];
// int age;
//};
//
//int main()
// {
// // 2. 单独定义变量s3、s4(用已声明的struct Stu类型)
// struct Stu s3, s4;
//
//
// return 0;
//}
//#include <stdio.h>
//
//// 1. 先声明内层结构体(坐标模板)
//struct Point
//{
// int x; // x轴坐标
// int y; // y轴坐标
//};
//
//// 2. 声明外层结构体(节点模板),成员包含struct Point
//struct Node
//{
// int data; // 节点数据
// struct Point p; // 嵌套的坐标结构体(内层结构体实例)
//};
//
//int main()
//{
// // 定义外层变量并初始化嵌套成员
// struct Node n = { 10, {3, 4} }; // data=10,p.x=3,p.y=4
// printf("节点数据:%d,坐标:(%d,%d)\n", n.data, n.p.x, n.p.y);
// return 0;
//}
//
//#include <stdio.h>
//int main() {
// char a = 127; // 有符号char最大值(二进制01111111)
// char b = 1;
// char c = a + b; // 预期128,实际结果为-128(溢出)
// printf("c = %d\n", c);
// return 0;
//}
//
//
//
//
//#include <stdio.h>
//int main() {
// int a = 127; // 有符号char最大值(二进制01111111)
// int b = 1;
// int c = a + b; // 预期128,实际结果为128
// printf("c = %d\n", c);
// return 0;
//}
//
//
//
////
//
//#include <stdio.h>
//int main() {
// unsigned int u = 3;
// int i = -5;
// if (u + i > 0) { // 预期为假(3-5=-2<0),实际为真
// printf("u + i > 0\n");
// }
// else {
// printf("u + i <= 0\n");
// }
// return 0;
//}
//#include <stdio.h>
//int main()
//{
// int u = 3;
// int i = -5;
// if (u + i > 0)
// { // 预期为假(3-5=-2<0),实际为真
// printf("u + i > 0\n");
// }
// else
// {
// printf("u + i <= 0\n");
// }
// return 0;
//}
#include <stdio.h>
int main()
{
int a = -3;
int b = 5;
int c = a & b;
printf("%d\n", c);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/donghua-wanli/blog-code.git
git@gitee.com:donghua-wanli/blog-code.git
donghua-wanli
blog-code
Blog code
master

搜索帮助