码迷,mamicode.com
首页 > 编程语言 > 详细

C++程序设计原理与实践 第十七章部分答案

时间:2014-11-10 23:12:22      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   for   

bubuko.com,布布扣
 1 #include <iostream>
 2 using namespace std;
 3 
 4 void to_lower(char* s)
 5 {
 6     while(*s!=\0)
 7     {
 8         if(*s>=A&&*s<=Z)
 9             *s+=32;
10         s++;
11     }
12 }
13 
14 char* strdup1(const char*s)
15 {
16     char *p=new char[];
17     cout<<sizeof(s)<<endl;               //////////注意
18     int i;
19     for(i=0;s[i]!=\0;i++)
20     {
21         p[i]=s[i];
22     }
23     p[i]=\0;
24     return p;
25 }
26 
27 char* findx(const char*s,const char*x)
28 {
29     int i=0;
30     while(*s!=\0)
31     {
32         while(*(s+i)==*(x+i)&&*(x+i)!=\0)
33         {
34             i++;
35         }
36         if(*(x+i)==\0)
37             return (char*)s;
38         else
39             i=0;
40         s++;
41     }
42     return NULL;
43 }
44 
45 int main()
46 {
47     //char c[]="D";
48     //cout<<sizeof(&c)<<endl;          //////////注意
49     //char *p=strdup1(c);
50 //    cout<<p<<endl;
51     char c1[]="fgasdfghj";
52     char c2[]="fgh";
53     cout<<findx(c1,c2);
54     while(1);
55     return 0;
56 
57 }
习题3 4 5
bubuko.com,布布扣习题10
bubuko.com,布布扣习题11
bubuko.com,布布扣习题14
习题12     应用与其他函数参数若是const Link&的话需用后者,因为后者已声明它不改变原有的值  P200  P377
 
 
 

C++程序设计原理与实践 第十七章部分答案

标签:style   blog   http   io   color   ar   os   sp   for   

原文地址:http://www.cnblogs.com/yueba/p/4088449.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!