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

 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
习题10
习题11
习题14
习题12     应用与其他函数参数若是const Link&的话需用后者,因为后者已声明它不改变原有的值  P200  P377
 
 
 

转载于:https://www.cnblogs.com/yueba/p/4088449.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值