Advertisement
Guest User

ggrgerg

a guest
Feb 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void citire (int a[20][20],int m, int n)
  6. {
  7. cout<<"m=";cin>>m;
  8. cout<<"n=";cin>>n;
  9. for (int i=0;i<n;i++)
  10. for (int j=0;j<m;j++)
  11. {
  12. cout<<"a["<<i<<"]["<<j<<"]=";
  13. cin>>a[i][j];
  14. }
  15. }
  16. void spirala (int a[20][20],int m, int n)
  17. {
  18. int i,k;
  19. for (k=0;k<=(n-1)/2;k++)
  20. {
  21. for (i=k;i<n-k;i++)
  22. cout<<a[k][i]<<" ";
  23. for (i=k+1;i<m-k;i++)
  24. cout<<a[i][m-k-1]<<" ";
  25. for (i=n-2-k;i>=k;i--)
  26. cout<<a[n-k-1][i]<<" ";
  27. for (i=n-k-2;i>k;i--)
  28. cout<<a[i][k]<<" ";
  29. }
  30. }
  31. int main ()
  32. {
  33. int a[20][20],m,n;
  34. citire (a,m,n);
  35. spirala (a,m,n);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement