Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- int row, col;
- cin >> row >> col;
- cin.ignore();
- string line;
- getline(cin, line);
- vector<vector<char>> matrix;
- int index = 0;
- for (int i = 0; i < row; i++) {
- vector<char> currentRow;
- for (int j = 0; j < col; j++) {
- if (i % 2 == 0) {
- currentRow.push_back(line[index++ % line.length()]);
- }
- else {
- currentRow.insert(currentRow.begin(), line[index++ % line.length()]);
- }
- }
- matrix.push_back(currentRow);
- }
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < col; j++) {
- cout << matrix[i][j];
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement