MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI SAMARQAND FILIALI
Kompyuter injiniringi fakulteti Dasturiy injiniringi yo’nalishi
Dasturlash uslublari va paradigmalar fanidan
1-Topshiriq
Bajardi:DI20-11 guruh Mamanazarov S
Tekshirdi: Mahmudov R
Samarqand 2022
package Hafta_1_mustaqil_yechish_uchun_topshiriqlar;
public class Misol_1 {
public static void main(String[] args) {
int[] arr = {5, 1, 3, 9, 12, 583, 998, 7538, 72, 53, 71, 85, 7, 2, 9};
int max = arr[0];
for (int i = 0; i < arr.length; i++) {
if (max < arr[i])
max = arr[i];
}
System.out.println("Massivning eng katta elementi:" + max);
}
}
package Hafta_1_mustaqil_yechish_uchun_topshiriqlar;
public class Misol_2 {
public static void main(String[] args) {
int[] arr = {5, 1, 3, 9, 12, 583, 998, 7538, 72, 53, 71, 85, 7, 2, 9};
int min = arr[0];
for (int i = 0; i < arr.length; i++) {
if (min > arr[i])
min = arr[i];
}
System.out.println("Massivning eng kichik elementi:" + min);
}
}
package Hafta_1_mustaqil_yechish_uchun_topshiriqlar;
public class Misol_5 {
public static void main(String[] args) {
int[] arr = {5, 1, 3, 0, 12, 0, 998, 0, 72, 53, 0, 85, 7, 2, 9};
int count = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 0)
count++;
}
System.out.println("Massivdagi nollar soni:" + count);
}
}
package Laboratoriya_1;
import java.util.Scanner;
public class Misol_1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char a1, a2, a3;
a1 = scanner.next().charAt(0);
a2 = scanner.next().charAt(0);
a3 = scanner.next().charAt(0);
boolean b1, b2, b3;
b1 = Character.isDigit(a1);
b2 = Character.isDigit(a1);
b3 = Character.isDigit(a1);
int result = 0;
if (b1 && b2 && b3)
result = 3;
else if ((b1 && b2) || (b1 && b3) || b2 && b3) {
result = 2;
}
else result = 1;
System.out.println(result);
}
}
package Laboratoriya_1;
import java.util.Scanner;
public class Misol_2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n, k;
n = scanner.nextInt();
k = scanner.nextInt();
int summ = 0;
summ = (faktrorial(n)) / (faktrorial(k) * (faktrorial(n - k)));
System.out.println("Natija:" + summ);
}
public static int faktrorial(int n){
if (n <= 0)
return 1;
return n * faktrorial(n - 1);
}
}
package Laboratoriya_1;
import java.util.Scanner;
public class Misol_3 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x;
x = scanner.nextInt();
x_gachaQoshibBer(x);
}
public static boolean toqmi(int x){
if (x % 2 == 1)
return true;
else
return false;
}
public static void x_gachaQoshibBer(int x){
int summ = 0;
for (int i = 1; i <= x; i++) {
if (toqmi(i))
summ += -i;
else summ += i;
}
System.out.println("Summa:" + summ);
}
}
Do'stlaringiz bilan baham: |