what is the error in my code ,why I am not getting the correct output.
Regarding error in my code
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int row=sc.nextInt();
int col=sc.nextInt();
int k=sc.nextInt();
int s=sc.nextInt();
if(row>=1&&col>=1&&k>=1&&s<=100){
String[][] str=new String[row][col] ;
for(int i=0;i<row;i++ ){
for(int j=0;j<col;j++){
str[i][j]=sc.nextLine();
}
}
int sr=0;
int sp=0;
while(sr<=row-1&&sp<=col-1){
String ss=str[sr][sp];
if(sp==col-1){
sr++;
}
else{
if(ss=="."){
s=s-2;
sp++;
sā;
}
else if(ss==""){
s=s+5;
sp++;
sā;
}
else if(ss=="#"){
sr++;
sp=0;
}
}
}
if(s>=k){
System.out.println("Yes");
System.out.println(s);
}
else{
System.out.println("No");
}
}
}
}
Mam ,please check my code
hey @Adhyayan
please use ide.codingblocks.com to save and share your code from the next time .its v difficult to understand raw code like this.
in your code,when u consider the last column case sp==col-1 ,u simply move to the next row ,u have not checked for the ā.ā or ā*ā or ā#ā and made the changes in s acc .