Untitled
unknown
java
3 years ago
1.5 kB
10
Indexable
//hoyni
import java.util.*;
class alphaMatrix {
//declaring as global variable
static ArrayList<ArrayList<Character>> matrix = new ArrayList<>();
static Scanner sc = new Scanner(System.in);
public static void requiredAns(int r,char toLook){
ArrayList<Character> prevRow=new ArrayList<>();
ArrayList<Character> prevCol=new ArrayList<>();
int f=0;
//dherr bal prevRow r prevCol ta kikore korboooo
//Main logic
/*for(int i=0;i<r;i++){
for(int j=0;j<r;j++){
if(matrix.get(i)){
System.out.println("Present");
f=1;
break;
}
if(f==1) {System.out.println("Present"); break;}
}
}
}
*/
//System.out.print(prevRow);
//System.out.println(prevCol);
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of rows: ");
int rows = sc.nextInt();
// Taking input for each row
for (int i = 0; i < rows; i++) {
System.out.print("Enter a string for row " + (i + 1) + ": ");
String rowInput = sc.next();
ArrayList<Character> row = new ArrayList<>();
// Adding each character in the string to the row
for (char c : rowInput.toCharArray()) {
row.add(c);
}
// Adding the row to the matrix
matrix.add(row);}
char find=sc.next().charAt(0);
requiredAns(rows,find);
}
}
Editor is loading...