Sveiki turiu bėdelę su iš pirmo tokia paprastute užduotim bet kai įsigilini tai žvėriškai sunku.
Yra duotas simbolių skaičius n. Toliau duota n simbolių vienam žody ir iš to žodžio simbolių padaryt reikia kvadratas pvz duomenys:
5 egzas
ir atsakymas turi gautis toks: e e e e e e e e e e g g g g g g g e e g z z z z z g e e g z a a a z g e e g z a s a z g e e g z a a a z g e e g z z z z z g e e g g g g g g g e e e e e e e e e e
pakeista prieš 5 m
UnknownPerson +1
#include <iostream> #include <string>
using namespace std;
int main(){ string x; long n,xlength; cin >> n >> x;
if(n == 1){cout << x[0]; return 0;}
xlength = x.length();
for(long i = 0; i < n-1; i++){ for(long y = 0; y <= i; y++){ cout << x[y] << " "; } for(long y = i; y <= xlength-i-4+n; y++){ cout << x[i] << " "; } for(long y = i; y > 0; y--){ cout << x[y] << " "; } cout << x[0] << "\n" << "\n"; }
for(long i = 0; i < xlength; i++){ cout << x[i] << " "; } for(long i = xlength-2; i > 0; i--){ cout << x[i] << " "; } cout << x[0] << "\n" << "\n";
for(long i = n-2; i >= 0; i--){ for(long y = 0; y <= i; y++){ cout << x[y] << " "; } for(long y = i; y <= xlength-i-4+n; y++){ cout << x[i] << " "; } for(long y = i; y > 0; y--){ cout << x[y] << " "; } cout << x[0] << "\n" << "\n"; }