fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. //cout << "Podaj liczbê testów" << endl;
  8.  
  9. int lt,x;
  10. int *tab,y,temp;
  11.  
  12. cin >> lt;
  13. int *tabW[lt];
  14. for(int i=0; i<lt; i++)
  15. {
  16.  
  17. cin >> x;
  18. tab = new int [x+1];
  19.  
  20. for(int j=0; j<x; j++)
  21. {
  22. cin >> y;
  23. tab[j]=y;
  24. //cout <<tab[j]<<" ";
  25. }
  26.  
  27. temp = tab[0];
  28. for(int k=0; k<x-1; k++)
  29. {
  30. tab[k]=tab[k+1];
  31. //cout <<tab[k]<<" ";
  32. }
  33. tab[x-1] = temp;
  34. tab[x] = 'X';
  35. //cout <<tab[x-1]<<" ";
  36. tabW[i] = tab;
  37.  
  38. }
  39.  
  40.  
  41. for(int n=0; n<lt; n++)
  42. {
  43.  
  44. int t =0;
  45. while(*(tabW[n]+t) != 'X'){
  46. cout <<*(tabW[n]+t)<<" ";
  47. t++;
  48. }
  49. cout <<endl;
  50.  
  51. }
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0s 15240KB
stdin
3
3 1 2 3
4 1 2 3 4
5 1 2 3 4 5
stdout
2 3 1 
2 3 4 1 
2 3 4 5 1