|
|
发表于 2021-6-17 11:01:04
|
显示全部楼层
s1e6
数据类型就是坑的大小
sizeof 是运算符
signed unsigned 是限定符 unsigned 不能存放负数
printf 有符号 用%d, 无符号用 %u
0,
可以尝试 用 long long int
1,
存储空间最小的是: 1个字节
2,
sizeof是运算符,所以也可以理解为一个函数
3,
32位系统是4个比特
4,
_bool
5,
F 是错误的
6,
因为unsigned int 没有符号,所以可以表示更大的整数
7,
只有对错,也就是1,0,不会有中间选项
动动手:
0,
- #include <stdio.h>
- #include <math.h>
- int main(){
- int result;
- result = pow(1,2)+pow(2,3)+pow(3,4)+pow(4,5)+pow(5,6);
- printf("the result is %i\n", result);
- return 0;
- }
复制代码
1,
- #include <stdio.h>
- #include <math.h>
- int main() {
- double sum=0;
- double temp;
- double weight;
- int i;
- for (i=0; i<64; i++){
- temp = pow(2,i);
- sum += temp;
- }
- weight = sum / 25000;
-
- printf("the King should give %.0f wheat\n",sum);
- printf("if 25000 wheat is 1kg, the it would be %.0f kg\n",weight)
- ;
- return 0;
- }
复制代码
notes from above: 比较理解了数据类型需要选择的,比如18446754654645这样的数字 int是放不下的,printf 也要根据数据类型选择 % 后边的字母
|
|