Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- main()
- {
- //2.2
- int k;
- cin >> k;
- int n;
- cin >> n;
- //ma_foykarznrtitu_ima_
- string S;
- cin >> S;
- int kolumny = n/k;
- char T[k][kolumny];
- int licz = 0;
- for(int i = 0; i < k; i++)
- {
- for(int j = 0; j < kolumny; j++)
- {
- T[i][j] = S[licz++];
- // cout << T[i][j];
- }
- }
- bool wDol = true;
- int i = 0;
- int j = 0;
- licz = 0;
- while(licz!=n)
- {
- if(wDol)
- {
- S[licz++] = T[i][j];
- i++;
- }
- else
- {
- S[licz++] = T[i][j];
- i--;
- }
- if(i==k-1)
- {
- S[licz++] = T[i][j];
- j++;
- wDol = false;
- }
- if(i==0)
- {
- S[licz++] = T[i][j];
- j++;
- wDol = true;
- }
- };
- cout << S;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement