#include <iostream>
using namespace std;
int main() {
int textLength = 0;
while ((cin >> textLength) && (textLength != 0)) {
string word = "";
cin>>word;
int group = word.length() / textLength;
for (int i = 0; i < word.length(); i += group) {
for (int j = i + group - 1; j >= i; j--) {
cout << word[j];
}
}
}
return 0;
}
題目網址
http://bit.ly/2mTqO7Y
補充:
字串翻轉
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char** argv) {
string str1 = "Xanxus";
for(int i = str1.length();i>=0;i--){
cout<<str1[i];
}
return 0;
}
沒有留言:
張貼留言