Guruh talabasi Ozodov Ozodbek


Download 75.46 Kb.
Sana25.04.2023
Hajmi75.46 Kb.
#1398606
Bog'liq
2-tajriba ishi


2-topshiriq:


  1. Bir o`lchamli sonli massiv ni 2 ga va 5 ga bo`linadigan elеmеntlarini ko`paytmasini sinusi tоpilsin


import java.util.Scanner;

// 1-Topshiriq
// 14. Bir o`lchamli sonli massiv ni 2 ga va 5 ga bo`linadigan elеmеntlarini ko`paytmasini sinusi tоpilsin
public class lab_2_1 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int n;
n = sc.nextInt();

int a[] = new int[n];

for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}

double s = 1;
for (int i = 0; i < n; i++) {
if (a[i] % 2 == 0 && a[i] % 5 == 0) {
s *= a[i];
}
}
System.out.println("2 va 5 ga bo`linadigan elementlarini ko`paytmasini sinusi sin("+ s +") = " + Math.sin(s));
}

}




2-topshiriq:

import java.util.Scanner;

public class lab_2_2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int n;
n = sc.nextInt();

int a[] = new int[n];

for (int i = 0; i < n; i++) {


a[i] = sc.nextInt();
}

double s = 0;


int k = 0;
for (int i = 0; i < n; i++) {
if (a[i] % 2 == 0) {
s += a[i];
k++;
}
}
System.out.println("Juft qiymatli elementlar o`rtacha qiymati-> " + s / k);
}
}



3-topshiriq:
public class lab_2_3 {
// 3-Topshiriq
// 14. Matritsani matritsaga va matritsani vеktоrga kupaytirish algоritmi va dasturi tuzilsin.

public static void main(String[] args) {
int a[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int b[] = {1, 2, 3};

int c[] = new int[3];


int s = 0;

for (int i = 0; i < 3; i++) {


for (int j = 0; j < 3; j++) {
s += a[i][j] * b[j];
}
c[i] = s;
s = 0;
}
for (int i = 0; i < 3; i++) {
System.out.println(c[i]);
}
}
}


Download 75.46 Kb.

Do'stlaringiz bilan baham:




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