Java: Savol: Jadval hosil qiling va unga ma’lumotlarni kiriting, ekranga chiqaring


Download 27.18 Kb.
Sana23.01.2023
Hajmi27.18 Kb.
#1112369
Bog'liq
MTA 1


Maluotlar tuzilmasi va algaritm
Matyakubov Odamboy
912-21-guruh
1-amaliyot
7-misol
Java:
Savol: Jadval hosil qiling va unga ma’lumotlarni kiriting, ekranga chiqaring.

package com.company;

import java.util.Scanner;

public class Matrix {


public static void main(String[] args) {
Scanner string = new Scanner(System.in);
String[][] matrix = null;
int qator = 0;
int ustun = 0;
Scanner scanner = new Scanner(System.in);
System.out.print("Qator va ustunlarni kiriting : ");
qator = scanner.nextInt();
ustun = scanner.nextInt();
matrix = new String[qator][ustun];
System.out.println("Mattritaningementlarini kiriting ");
for (int i = 0; i < qator; i++) {
for (int j = 0; j < ustun; j++) {
System.out.print("Element[" + i + "][" + j + "]: ");
matrix[i][j] = string.nextLine();
}
}
System.out.println("\nJadval ");
for (String[] i : matrix) {
for (String j : i) {
System.out.print(j + " ");
}
System.out.println();
}
}
}


Download 27.18 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling