标签:
输入例子: aabcd 输出例子: a aa aab aabc ab abc b bc bcd c cd d
#include <iostream> #include <string.h> using namespace std; void Grial(char *str) { int n = strlen(str); while(*str!='\0') { for(int i = 1;i<=n;i++) { char s[i]; memcpy(s,str,i); *(s+i)='\0'; cout<<s<<endl; } str++; n--; } } int main() { char s[]="nwlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmcoqhnwnkuewhsqmgb"; Grial(s); return 0; }
nwlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmcoqhnwnkuewhsqmgb,我测试了也没有错。我是在ubantu系统下面的g++编译器,有人帮我看一下吗?
C++牛客网上的题(我做的测试了都是对的,它却说是错的,虽然写的很不好,可是每错啊,求大家看看)
标签:
原文地址:http://blog.csdn.net/liuhuiyan_2014/article/details/45345739