fork download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. string a;
  7. cin>>a;
  8. int ile,b;
  9. cin>>ile;
  10. while(ile--)
  11. {
  12. cin>>b;
  13. if(b==0)
  14. {
  15. cout<<a[a.length()-1];
  16. }
  17. if(b>0)
  18. {
  19. b=b-1;
  20. for(int i=0;i<a.length();i++)
  21. {
  22. cout<<a[i];
  23. for(int i=0;i<b;i++)
  24. {
  25. cout<<" ";
  26. }
  27. }
  28. }
  29. if(b<0)
  30. {
  31. b=b*-1;
  32. b=b-1;
  33. for(int i=a.length()-1;i>=0;i--)
  34. {
  35. cout<<a[i];
  36. for(int i=0;i<b;i++)
  37. {
  38. cout<<" ";
  39. }
  40. }
  41. }
  42. cout<<endl;
  43. }
  44. }
Success #stdin #stdout 0.01s 5496KB
stdin
FRAKTAL
5
-2
-1
0
1
2
stdout
L A T K A R F 
LATKARF
L
FRAKTAL
F R A K T A L