|
// Har bir sonning raqamlar yig'indisini ekranga chiqarish
|
bet | 4/8 | Sana | 18.05.2024 | Hajmi | 0,9 Mb. | | #242341 |
Bog'liq 7ish00 // Har bir sonning raqamlar yig'indisini ekranga chiqarish for (int i = 0; i < N; i++) { System.out.println((i + 1) + "-sonning raqamlar yig'indisi: " + yigindilar.get(i)); } } } }
package javafx;
import java.io.*; import java.net.*;
public class Server { public static void main(String[] args) throws IOException { // Server soketini yaratish try (ServerSocket serverSocket = new ServerSocket(5000)) { System.out.println("Server ishga tushdi..."); while (true) { try (Socket clientSocket = serverSocket.accept()) { System.out.println("Klient ulandi...");
// Klientdan diagonallarni qabul qilish BufferedReader input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); double d1 = Double.parseDouble(input.readLine()); double d2 = Double.parseDouble(input.readLine()); System.out.println("Qabul qilingan diagonallar: d1 = " + d1 + ", d2 = " + d2);
// Rombning yuzasini hisoblash double yuza = (d1 * d2) / 2;
// Klientga yuzani yuborish PrintWriter output = new PrintWriter(clientSocket.getOutputStream(), true); output.println(yuza); System.out.println("Rombning yuzasi: " + yuza + " klientga yuborildi."); } } } } }
package javafx;
import java.io.*; import java.net.*;
public class Server { public static void main(String[] args) throws IOException { // Server soketini yaratish try (ServerSocket serverSocket = new ServerSocket(5000)) {
|
| |