C++编程
1. 给定一个字符串,它包含了大量由空格分隔的单词,例如“dogs eat bones”。试构造一个函数,创建一个新字符串(不需要原地转换),将给定字符串中的单词反序,上例中即为“bones eat dogs” 用c++ 简单实现关键代码~~~
#include #include void main() { char str[]="dogs eat bones"; char newstr[30]; int i=0,j,len; j=len=strlen(str); while(i
用string里面的find找到每一个空格再用substr把从前一个一个空格后到这个空格前提取出来,然后用strcat把新提取出的单词接到答案string的前面
答:若要C语法,请用注释后的内容替换所在的行. #include //#include "stdio.h" using namespace std; ...详情>>
问:挺简单的一C函数,不过我是初学者,暂时还不会写,请好心人多多帮忙!
答:int mystrlen(char *str) { int n = 0; while (*str) { n++; str++;} return n; } voi...详情>>