VS parse(string& s) { VS v; for (int i = s.FN(' '); i < s.length(); i = s.FN(' ', i)) { char c = s[i]; if (is_num(c)) { int j = s.FN(NUMS, i); if (j == string::npos) { v.PB(s.substr(i)); break; } v.PB(s.substr(i, j - i)); i = j; } else if (is_func(c)) { int j = s.FN(FUNS, i); v.PB(s.substr(i, j - i)); i = j; } else { v.PB(s.substr(i, 1)); i += 1; } } return v; }
int main() { VVI vv; VI v(3); v[0] = 1; v[1] = 5; v[2] = 6; vv.PB(v); v[0] = 2; v[1] = 7; v[2] = 8; vv.PB(v); REPSZ(i, vv) print(vv[i]); // sort(vv.begin(), vv.end(), cmpVector); REPSZ(i, vv) print(vv[i]); cout << "//////"<<endl; VI v2; v2.PB(2); v2.PB(1); v2.PB(3); sort(v2.begin(), v2.end(), mycmp); // sort(v2.begin(), v2.end()); print(v2); VS vs; vs.PB("12"); vs.PB("9"); vs.PB("312"); sort(vs.begin(), vs.end(), sss); print(vs); }
VS parse(string s) { string a; VS wyn; REP(i,(int)s.size()) if (s[i]!=' ') a+=s[i]; else if (!a.empty()) { wyn.PB(a); a=""; } if (!a.empty()) wyn.PB(a); return wyn; }
int main() { char str[100]; while(scanf("%s",str)) { int len=strlen(str); int ar[100]; for( int i=0; i<len; i++ ) ar[i]=i; VS v; string st; sort(ar,ar+len); do { for( int i=0; i<len; i++ ) st+=str[ar[i]]; v.PB(st); st.clear(); } while(next_permutation(ar,ar+len)); for( int i=0; i<v.size()/len; i++ ) { for( int j=i; j<v.size(); j+=7 ) cout<<v[j]<<endl; } v.clear(); printf("\n"); } return 0; }
ostream& operator<<(ostream& out, const SS& s) { VS v; SS ss = s; while (!ss.empty()) { v.PB(ss.top()); ss.pop(); } for (int i = v.size() - 1; i >= 0; i--) out << v[i] << ' '; return out; }
main() { int n,str,len,sp; while(cin>>n) { str=0; sp=n; string st; for( int i=1; i<=(n/2)+1; i++ ) { if( i%2 == 1 ) { for( int j=1; j<=str/2; j++ ) if( j % 2 == 1) st+="#"; else st+=" "; for( int j=1; j<=sp; j++) st+="#"; for( int j=1; j<=str/2; j++ ) if( j % 2 == 1 ) st+=" "; else st+="#"; } else { for( int j=1; j<=ceil(str/2); j++ ) if( j%2 == 1) st+="#"; else st+=" "; for( int j=1; j<=sp; j++ ) st+=" "; for( int j=1; j<=ceil(str/2); j++ ) if( j % 2 == 1 ) st+="#"; else st+=" "; } sp=sp-2; str+=2; v[i].PB(st); st.clear(); //cout<<endl; } for( int j=1; j<=n; j++ ) if( j%2 == 1 ) st+="#"; else st+=" "; v[(n/2)+2].PB(st); VS ret; for( int i=0; i<(n/2)+2; i++ ) { string tmp; for( int j=0; j<v[i].size(); j++ ) tmp+=v[i][j]; ret.PB(tmp); tmp.clear(); } for( int i=(n/2); i>=0; i-- ) { string tmp; for( int j=0; j<v[i].size(); j++ ) tmp+=v[i][j]; ret.PB(tmp); tmp.clear(); } //ret.PB(ret[0]); for( int i=0; i<n+1; i++ ) cout<<ret[i]<<endl; for( int i=0; i<v[i].size(); i++ ) v[i].clear(); } }
VS split(string &s, char c = ' ') {VS all; int p = 0, np; while (np = s.find(c, p), np >= 0) {if (np != p) all.PB(s.substr(p, np - p)); p = np + 1;} if (p < SIZE(s)) all.PB(s.substr(p)); return all;}
VS splt(string s, char c = ' ') {VS rv; int p = 0, np; while (np = s.find(c, p), np >= 0) {if (np != p) rv.PB(s.substr(p, np - p)); p = np + 1;} if (p < (int)s.S) rv.PB(s.substr(p)); return rv;}