提高篇第28-31课第三题
来源:互联网 发布:云南大学网络平台 编辑:程序博客网 时间:2024/06/05 11:59
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>//第三题void cpyStr0(char str1[], char str2[]);void cpyStr1(char str1[], char str2[]);void cpyStr2(char str1[], char str2[], char str3[]);void cpyStr3(char str1[], char str2[]);void cpyStr4(char str1[], char str2[], char str3[]);int main(){char str[100] = "I am a happy boy\'s daddy.", str_0[100],str_1[100], str_2[100], str_3[100], str_4[100];cpyStr0(str, str_0);puts(str);puts(str_0);cpyStr1(str, str_1);puts(str_1);cpyStr2(str, str_0, str_2);puts(str_2);cpyStr3(str, str_3);puts(str);cpyStr4(str_1,str_0,str_4);puts(str_1);return 0;}void cpyStr0(char str1[], char str2[]){int i = 0, j = 0;while (str1[i] != '\0'){if (str1[i] != ' '){str2[j] = str1[i];j++;}i++;}str2[j] = '\0';//切记!!}void cpyStr1(char str1[], char str2[]){int i = 0, j = 0;while (str1[i] != '\0'){str2[j] = str1[i];j++;i++;}str2[j] = '\0';}void cpyStr2(char str1[], char str2[], char str3[]){strcpy(str3, str1);strcat(str3, str2);}void cpyStr3(char str1[],char str2[]){int i = 0, j = 0;while (str1[i] != '\0'){if (str1[i] != ' '){str2[j] = str1[i];j++;}i++;}str2[j] = '\0';//切记!!strcpy(str1, str2);}void cpyStr4(char str1[], char str2[], char str3[]){strcpy(str3, str1);strcat(str3, str2);strcpy(str1, str3);}
0 0
- 提高篇第28-31课第三题
- 提高篇第2-5课第三题
- 提高篇第6-10课作业第三题
- 提高篇第16-19课第三题
- 提高篇第20-21课第三题
- 提高篇第26-27课第三题
- 提高篇第28-31课第一题
- 提高篇第28-31课第二题
- 第三章第28题
- 第32课第三题
- 第33课第三题
- 第35课第三题
- 第36课第三题
- 第37课第三题
- 第39课第三题
- 第43课第三题
- 提高篇第2-5课第一题
- 提高篇第2-5课第二题
- 第十六周阅读程序(2)
- TOMCAT启动时报错:the CATALINA_HOME environment variable is not defined correctly
- Lucene:基于Java的全文检索引擎简介
- Centos 6.2 安装Mysql笔记
- SlidingMenu使用(二) Demo
- 提高篇第28-31课第三题
- org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 40
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph (sorting + dp)
- codeforces Round#158 Div.2 C
- Hihocoder 顺子
- 黑马程序员JAVA笔记1--java基础和概述
- adroid 杂项
- win7 64位pl/sql配置
- 组网