
K.R例题与习题recode
文章平均质量分 67
NotAnyMore_HCWY
记录 提高
展开
-
atoi函数:将s转换为整形数
#include#include /* atoi function:change string to integer**//*if there is space in the head,skip it*//*if it is "+" or "-" in the head,read it*/int atoi(char s[]){ int i=0;//counter原创 2014-03-20 10:14:32 · 989 阅读 · 0 评论 -
reverse函数 倒置字符串各个字符位置 3.5
#include#include #include /* reverse function,reverse every char in the sting s*/void reverse(char s[]){ //remember the strlen() function int j=0; int tmp; printf("\nlll"); //the f原创 2014-03-20 10:41:15 · 623 阅读 · 0 评论 -
扩展速记符号字符串 练习3-3
因为对string类不是很熟悉,不知道如何在string后面直接插入一个字符,所以不得已用指针而为之,缺陷就是一开始必须显示规定扩展字符串的大小。后面有时间了用string来实现以下。不得不得不夸一下K.R这本书,给出的例子或是习题虽然用到的语法规则很简单,但都需要思考一番才能做出来,适合我这种需要提高的菜鸟。 #include #include #includeus原创 2014-03-20 12:09:23 · 1098 阅读 · 0 评论 -
itoa函数:将数字n转换为字符串并保存到s中 3.6例题实现
#include #include #includeusing namespace std;void reverse(char s[]);/*itoa function,change integer into string,savd in s[];*/char* itoa(int n);int main(){ //test and I alway原创 2014-03-20 16:35:02 · 896 阅读 · 0 评论 -
3.6例题实现方法
与书上的实现相比,自己的实现增加了自动判断字符串大小的部分 从而动态分配数组#include #include #includeusing namespace std;void reverse(char s[]);/*itoa function,change integer into string,savd in s[];*/char* itoa(int n);原创 2014-03-20 16:37:11 · 580 阅读 · 0 评论