![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
明解C语言
DiscoYang
立一个码农的FLAG
展开
-
《明解C语言(入门篇)》练习11-10
/* 编写函数,实现与库函数atoi、atol、atof相同的功能 */ #include <stdio.h> int strtoi(const char *nptr) { int ans = 0; int sign = 1; while (*nptr == ' ') nptr++; if (*nptr == '+') { nptr++; } else if (*nptr == '-') { sign = -1; nptr++; } while (*n原创 2021-02-24 12:13:37 · 161 阅读 · 1 评论 -
《明解C语言(入门篇)》练习7-4
/* 编写set函数,返回将无符号整数x的第pos位设为1后的值 编写reset函数,返回将无符号整数x的第pos位设为0后的值 编写inverse函数,返回将无符号整数x的第pos位取反后的值 */ #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while (x) { if (x & 1U) bits++; x >>= 1; }原创 2021-02-16 23:13:06 · 280 阅读 · 0 评论 -
《明解C语言(入门篇)》练习5-9
/* 输入学生的分数并纵向显示分布图 */ #include <stdio.h> #define NUMBER 80 int main() { int num, max_bunpu; int tensu[NUMBER]; int bunpu[11] = {0}; printf("请输入学生人数:"); do { scanf("%d", &num); if (num < 1 || num >原创 2021-02-16 00:28:47 · 405 阅读 · 1 评论