#include<bits/stdc++.h>
using namespace std;
void printSpiral(int arr[100][100],int r ,int c ){
int rowStart=0;
int rowEnd=r-1;
int colStart=0;
int colEnd=c-1;
while (rowStart<=rowEnd && colStart<=colEnd)
{
for (int i=colStart;i<=colEnd;i++ ){
cout<<arr[rowStart][i]<<" “;
}
rowStart++;
for (int i=rowStart;i<=rowEnd;i++ ){
cout<<arr[i][colEnd]<<” “;
}
colEnd–;
for (int i=colEnd;i>=colStart;i-- ){
cout<<arr[rowEnd][i]<<” “;
}
rowEnd–;
for (int i=rowEnd;i>=rowStart;i++ ){
cout<<arr[i][colStart]<<” ";
}
colStart++;
}
return ;
}
int main()
{
int r,c ;
cin>>r>>c;
int arr[100][100]={0};
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cin>>arr[i][j];
}
}
printSpiral(arr,r,c);
return 0;
}
Segmentation Fault Core Dump
hello @NimeshJohari02
pls go to this link -> https://ide.codingblocks.com/
paste ur code , press ctrl + s and then save
a url will be generated in ur search bar , share that url with me
CHECK NOW->
Ohh Got it Thanks a lot !
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.