随笔分类 -  c/c++

上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 30 下一页
摘要:编写set_n函数,返回将无符号整数x的第pos位到第pos + n - 1 位的 n 位 设为1后的值。 1、 #include <stdio.h> unsigned set_n(unsigned x, int pos, int n) { int i; for(i = pos; i <= pos 阅读全文
posted @ 2021-05-19 18:14 小鲨鱼2018 阅读(64) 评论(0) 推荐(0)
摘要:编写reverse函数,返回将无符号整数x的第pos位取反后的值。 1、 #include <stdio.h> unsigned reverse(unsigned x, int pos) { if(x >> pos & 1U) return (x & (~(1 << pos))); else ret 阅读全文
posted @ 2021-05-19 17:36 小鲨鱼2018 阅读(63) 评论(0) 推荐(0)
摘要:编写reset函数,返回无符号整数x的第pos为设为0后的值。 1、 #include <stdio.h> unsigned reset(unsigned x, int pos) { return (x & (~(1 << pos))); } int main(void) { unsigned x; 阅读全文
posted @ 2021-05-19 16:39 小鲨鱼2018 阅读(55) 评论(0) 推荐(0)
摘要:编写函数,返回将无符号整数的第pos位设置为1后的值。 1、 #include <stdio.h> unsigned set(unsigned x, int pos) { return (x | 1 << pos); } int main(void) { unsigned x; int n; put 阅读全文
posted @ 2021-05-19 13:02 小鲨鱼2018 阅读(76) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> unsigned rrotate(unsigned x, int n) { printf("rrotate = %u\n", x >> n); } unsigned lrotate(unsigned x, int n) { printf("lrotate 阅读全文
posted @ 2021-05-18 21:30 小鲨鱼2018 阅读(67) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <math.h> int main(void) { unsigned x; int n; puts("please input an unsigned number and an integer."); printf("x = "); s 阅读全文
posted @ 2021-05-18 19:56 小鲨鱼2018 阅读(79) 评论(0) 推荐(0)
摘要:c语言中按位逻辑运算符、位移运算符 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; } int int_bits(v 阅读全文
posted @ 2021-05-18 12:37 小鲨鱼2018 阅读(146) 评论(0) 推荐(0)
摘要:c语言中按位逻辑运算符、位移运算符 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; } int int_bits(v 阅读全文
posted @ 2021-05-18 12:35 小鲨鱼2018 阅读(135) 评论(0) 推荐(0)
摘要:#include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; } int int_bits(void) { return coun 阅读全文
posted @ 2021-05-17 21:21 小鲨鱼2018 阅读(266) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { int n; printf("sizeof(1) = %u\n", (unsigned)sizeof(1)); printf("sizeof(+1) = %u\n", (unsigned)sizeof(+1)); prin 阅读全文
posted @ 2021-05-16 21:11 小鲨鱼2018 阅读(150) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> void fun(void) { static int times = 0; times++; printf("put_count: %d\n", times); } int main(void) { int n; puts("please input a 阅读全文
posted @ 2021-05-11 12:27 小鲨鱼2018 阅读(62) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #define NUMBER 5 int main(void) { static double array[NUMBER]; int i; for(i = 0; i < NUMBER; i++) { printf("array[%d] = %.1f\n", 阅读全文
posted @ 2021-05-11 12:13 小鲨鱼2018 阅读(48) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> void sumup(int x[2][4][3], int y[4][3]) { int i, j, k; for(i = 0; i < 4; i++) { for(j = 0; j < 3; j++) { for(k = 0; k < 2; k++) 阅读全文
posted @ 2021-05-11 11:59 小鲨鱼2018 阅读(59) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> void multiply(int x[4][3], int y[3][4], int z[4][4]) { int i, j, k; for(i = 0; i < 4; i++) { for(j = 0; j < 4; j++) { for(k = 0; 阅读全文
posted @ 2021-05-11 11:32 小鲨鱼2018 阅读(63) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #define NUMBER 7 int search(const int x[], int y[], int key, int n) { int i, times = 0; for(i = 0; i < n; i++) { if(x[i] == key) 阅读全文
posted @ 2021-05-11 11:13 小鲨鱼2018 阅读(76) 评论(0) 推荐(0)
摘要:c语言 6-5 #include <stdio.h> int sumup(int n) { int sum = 0; int i; for(i = 1; i <= n; i++) { sum += i; } return sum; } int main(void) { int i; puts("pl 阅读全文
posted @ 2021-05-07 10:14 小鲨鱼2018 阅读(85) 评论(0) 推荐(0)
摘要:c语言6-4 #include <stdio.h> int sqr(int a) { return a * a; } int pow4(int a) { return sqr(sqr(a)); } int main(void) { int i; puts("please input an integ 阅读全文
posted @ 2021-05-07 10:08 小鲨鱼2018 阅读(80) 评论(0) 推荐(0)
摘要:c语言 6-3 #include <stdio.h> int cube(int a) { return a * a * a; } int main(void) { int i; puts("please input an integer."); printf("i = "); scanf("%d", 阅读全文
posted @ 2021-05-07 10:03 小鲨鱼2018 阅读(91) 评论(0) 推荐(0)
摘要:输出三个数中的最小值。 #include <stdio.h> int min3(int a, int b, int c) { int min = a; if(b < min) min = b; if(c < min) min = c; return min; } int main(void) { i 阅读全文
posted @ 2021-05-07 10:00 小鲨鱼2018 阅读(1838) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int min2(int a, int b) { int min = a; if(b < min) min = b; return min; } int main(void) { int x, y; puts("please input two integ 阅读全文
posted @ 2021-05-06 23:20 小鲨鱼2018 阅读(83) 评论(0) 推荐(0)

上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 30 下一页