Sir, can u please find my mistake?

#include
using namespace std;
int main() {

int m, n ; cin >> m >> n ;
int a[m][n];
for(int r= 0 ; r<m; r++) {
	for (int c= 0 ; c<n; c++) {
		cin>> a[r][c];
	}
}

int sr=0;
int sc=0;
int er=m-1;
int ec=n-1;

while(sc<ec && sr<er) {
    
	for(int i=0; i<=ec; i++){
		cout << a[sr][i] << " ";
	}
	sr++;

	for(int i=sr; i<=er ; i++ ){
		cout << a[i][ec] << " ";
	}
    ec--;

	for(int i=ec; ec>= sc; i++) {
		cout << a[er][i] << " ";
	}
	er--;

	for(int i=er; er>=sc; i++ ){
		cout << a[i][sc] << " ";
	}
	sc++;
}


return 0;

}

hello @chandreshmaurya

pls save ur code here-> https://ide.codingblocks.com/
and share its link with me

sir, no link is generating here

sir, how can i share my code ?

go to this link ->

paste ur code in the editor ,
press ctrl + s and then save
a link will be generate in the search bar (where u search) ,share that link with me
something like this->

sir, this is my code. please help me to find my error —> https://ide.codingblocks.com/s/445309

@chandreshmaurya
check now->

now the major issue in ur code is , we have to print in anticlockwise but u r printing clockwise

sir, actually, there is coming a compilation error? how can i tackel that?

you should give input in input box ,before pressing run button

check here->

i have mentioned input as well

sir, some elements prints multiple times.

pls mention the test case, it willl help me in furthur debugging

sir, how can i send ss of my output?

3 4 1 2 3 4 5 6 7 8 9 10 11 12

no need, i can run and see from my time.

to remove it keep track of number of element u have printed so far.
the moment count== n * m break

sir, please can u send your code? i did a lot , but i’m stucking somewhere.

here is my code --> https://ide.codingblocks.com/s/445309

@chandreshmaurya
check here->

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.