#include#include #include using namespace std; string DeletEmpty( char *c ){ string fs[strlen(c)]; string fstr; int n=0; for( int x=0 ; x < strlen(c) ; x++ ){ if( c[x] != ' ' ){ // 不是 空白 就存入 不然就換下一個 fs[n] += c[x]; }else n++; } for( int x=0 ; x < strlen(c) ; x++ ){ fstr += fs[x]; //把所有 字串 合併 } return fstr; } int main(){ char c[50]; gets(c); string s = DeletEmpty(c); cout << s; }
沒有留言:
張貼留言