int a[][] = new int[n][m];
Quyidagi dasturda matritsa elementlarini kiritish, chiqarish va yig’indisini xisoblash amalga oshirilgan.
import java.util.Scanner;
public class Misol3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n,m;
n = sc.nextInt();
m = sc.nextInt();
int a[][] = newint[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = sc.nextInt();
}
}
//matritsanichiqarish for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
System.out.print(a[i][j]+" ");
}
System.out.println("");
}
int s = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
s += a[i][j];
}
}
System.out.println("mtritsa elementlari yig`indisi "+s);
}
}
Topshiriqlar. 1-topshiriq: Bir o`lchamli sonli massivni o`rtacha qiymatidandan kichik elеmеntlarini o`rtacha qiymati хisоblansin.