Advertisement
madidino

teza7-sub3-2

Nov 12th, 2023 (edited)
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void permuta(int n,int a[],int k)
  4. {
  5.     int v[100];
  6.     int j=1;
  7.  
  8.     for(int i=k+1; i<=n; i++)
  9.     {
  10.         v[j]=a[i];
  11.         j++;
  12.     }
  13.     for(int i=1; i<=k; i++)
  14.     {
  15.         v[j]=a[i];
  16.         j++;
  17.     }
  18.     for(int i=1; i<=n; i++)
  19.     {
  20.         a[i]=v[i];
  21.     }
  22. }
  23. int main()
  24. {
  25.     int a[] = {0,60,45,30,10};
  26.     permuta(4,a,2);
  27.     for(int i=1;i<=4;i++)
  28.     {
  29.         cout << a[i] << " ";
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement