Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void citire (int a[20][20],int m, int n)
- {
- cout<<"m=";cin>>m;
- cout<<"n=";cin>>n;
- for (int i=0;i<n;i++)
- for (int j=0;j<m;j++)
- {
- cout<<"a["<<i<<"]["<<j<<"]=";
- cin>>a[i][j];
- }
- }
- void spirala (int a[20][20],int m, int n)
- {
- int i,k;
- for (k=0;k<=(n-1)/2;k++)
- {
- for (i=k;i<n-k;i++)
- cout<<a[k][i]<<" ";
- for (i=k+1;i<m-k;i++)
- cout<<a[i][m-k-1]<<" ";
- for (i=n-2-k;i>=k;i--)
- cout<<a[n-k-1][i]<<" ";
- for (i=n-k-2;i>k;i--)
- cout<<a[i][k]<<" ";
- }
- }
- int main ()
- {
- int a[20][20],m,n;
- citire (a,m,n);
- spirala (a,m,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement