Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void citire(int a[][100],int &n,int &k)
  6. {
  7.     cout<<"n=";cin>>n;
  8.     cout<<"k=";cin>>k;
  9.     for(int i=0;i<n;i++)
  10.         for(int j=0;j<n;j++)
  11.             cin>>a[i][j];
  12. }
  13.  
  14. void perm(int a[][100],int n,int l)
  15. {
  16.     int aux;
  17.     aux=a[l][0];
  18.     for(int i=0;i<n;i++)
  19.         a[l][i]=a[l][i+1];
  20.     a[l][n-1]=aux;
  21. }
  22.  
  23. void solve(int a[][100],int &n,int k)
  24. {
  25.     for(int j=0;j<n;j++)
  26.         for(int i=0;i<k;i++)
  27.             perm(a,n,j);
  28. }
  29.  
  30. void scriere(int a[][100],int &n)
  31. {
  32.     cout<<endl;
  33.     for(int i=0;i<n;i++)
  34.         {for(int j=0;j<n;j++)
  35.             cout<<a[i][j]<<" ";
  36.         cout<<endl;}
  37. }
  38.  
  39.  
  40. int main()
  41. {
  42.     int a[100][100],n,k;
  43.     citire(a,n,k);
  44.     solve(a,n,k);
  45.     scriere(a,n);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement