Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- #include <string>
- #include <algorithm>
- #include <vector>
- #include <sstream>
- using namespace std;
- string prom(string l)
- {
- string h="";
- int o = 4 - l.size();
- for (int i = 0; i < o ; i++)
- h += ' ';
- return h;
- }
- string convertInt(int number)
- {
- stringstream ss;
- ss << number;
- return ss.str();
- }
- void d(int n, int k, vector <string> russian)
- {
- string h;
- int j;
- j = 0;
- double q = k;
- int f = ceil(n/q);
- for (int i = 1; i <= f; i++)
- {
- h = "";
- if (j != n-f*(k-1))
- {
- for (int p = 0; p < k; p++)
- {
- h += prom(russian[p*f + i-1]);
- h += russian[p*f + i-1];
- }
- j++;
- }
- else
- {
- for (int p = 0; p < k - 1; p++)
- {
- h += prom(russian[p*f + i - 1]);
- h += russian[p*f + i - 1];
- }
- h += " ";
- }
- cout << h << endl;
- }
- }
- int main()
- {
- long long n, k, l;
- vector <string> russian;
- string prom;
- cin >> n >> k;
- for (int i = 1; i <= n; i++)
- {
- cin >> l;
- prom = convertInt(l);
- russian.push_back(prom);
- }
- d(n, k, russian);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment