Wrote the same code but getting error

#include
using namespace std;

void magical_park(char a[][100] , int m , int n , int k , int s)
{
bool success = true;

for(int i=0;i<m;i++){
	for(int j=0;j<n;j++){
		char ch = a[i][j];

		//check
		if(s<k){
			success = false;
			break;
		}
		if(ch=='*'){
			s+= 5;
		}
		else if (ch=='.'){
			s -= 2;
		}
		else{
			//if hash
			break;
		}
		//we also lose 1 point when we move right except the last column.
		if(j!= n-1){
			s--;
		}
	}	
}

if(success){
	cout<<"Yes"<<" ";
	cout<<s<<endl;
}
else{
	cout<<"Not successful"<<" ";
}

}
int main() {
int m , n , k ,s;
cin >> m >> n >> k >> s;

char park[100][100];
for(int i=0;i<m;i++){
	for(int j=0;j<n;j++){
		cin>>park[i][j];
	}
}
magical_park(park , m , n , k , s);
return 0;

}

Hello @rijulsingh1,

Please, share your code using Coding Blocks IDE.
The way you have shared it may introduce many syntax errors to it.

STEPS:

  1. Paste the code at https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.

Hi , I am running the code on ide but there is no link generated.

https://ide.codingblocks.com/s/202946

When testing I pass only 2 out of 5 test cases .

Hello @rijulsingh1,

I have corrected your code:


Refer to the comments for better understanding.

Give a like if you are satisfied.

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.