满分求解五道c++题(2)
6.编写一个程序,主函数中定义并输入字符串,调用子函数,将字符串中字符按正(逆)序排列,主函数中输出结果。 7.编写一个程序,主函数中定义并输入字符串,分别调用子函数(自定义),统计(0-9)数值的个数、(a-z、A-Z)字符的个数、空格的个数,主函数中输出结果。 8.编写一个程序,主函数中定义并输入二个字符串,调用子函数(自定义),比较二个字符串的大小,主函数中输出结果。 9.编写一个程序,主函数中定义二个字符数组(或字符串),输入其中一个字符串,调用子函数(自定义),实现字符串的拷贝,主函数中输出结果。 10.编写一个程序,主函数中定义并一个输入字符串,调用子函数(自定义)统计字符串中的字符实际个数,主函数中输出结果。
#include #include using namespace std; 第1题: char * strtolwr(char *str) { assert(str != NULL); char *tmp = str; while(*str) { if(*str >= 'A' && *str >str; strtolwr(str); cout= 'a' && *str >str; strtoupr(str); cout>str; cout>ch; int res = findchar(str, ch); if(res == 0) { cout>longstr; cout>shortstr; char *tmp; char *tmplong = longstr; int count = 0; cout>str1; cout>str2; catstr(str1, str2); cout<
#include #include using namespace std; 第6题: void orderstr(char *str) { assert(str != NULL); int i,j,k; int len = strlen(str); char tmp; for(i=0; i str[j]) { k = j; } } if(k != i) { tmp = str[i]; str[i] = str[k]; str[k] = tmp; } } } void main() { char str[100]; cout>str; orderstr(str); cout= '0' && *str = 'a' && *str = 'A' && *str *str2) { return 1; } else if (*str1 == *str2) { str1++; str2++; } else { return -1; } } if(*str1 == '\0' && *str2 != '\0') { return -1; } else if(*str1 != '\0' && *str2 == '\0') { return 1; } else { return 0; } } void main() { char str1[100]; char str2[100]; cout>str1; cout>str2; int res = cmpstr(str1, str2); if(res == -1) { cout str2">strSrc; cpystr(strDest, strSrc); cout>str; int count = strSize(str); cout<<"字符个数:"<
说的这么详细,为什么要别人设计
答:#include #include using namespace std; 第1题: char * strtolwr(char *str) { asser...详情>>
问:挺简单的一C函数,不过我是初学者,暂时还不会写,请好心人多多帮忙!
答:int mystrlen(char *str) { int n = 0; while (*str) { n++; str++;} return n; } voi...详情>>