编程学C语言
weixin_42505877
资料来源于网络,如有侵权请联系删除
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
4. C语言动态内存分配
#include <stdio.h> #include <stdlib.h> #include <string.h> struct woman { char name[50]; int age; }; int main(int argc, char *argv[]) { int *pi = malloc(sizeof(int)); long *pl = mall...原创 2020-03-01 15:16:17 · 91 阅读 · 0 评论 -
3. 计算输入数字的二进制表示中含有1的个数
#include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main() { unsigned int x = 9; int countx = 0; while(x) { countx++; x &= (x-1); } printf("%d\n",...原创 2020-02-05 15:56:33 · 134 阅读 · 0 评论 -
2. C语言实现字符串倒置
#include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main() { char *src = “hello world”; char dest = NULL; int len = strlen(src); dest = (char)malloc(l...原创 2020-02-05 12:57:08 · 754 阅读 · 0 评论 -
1. 打印1-100的素数
思考:偶数不可能是素数,缩小范围,减小计算量,奇数中只能被自己和1整除的数就是素数。 #include <stdio.h> #include <stdlib.h> int main() { int number; int divisor; printf("1\n2\n"); for(number = 3; number <= 100; number = number...原创 2020-01-27 14:21:27 · 134 阅读 · 0 评论
分享