Guruh: Abdumutalipov Shaxzodbek 7-raqam
Download 118.92 Kb.
|
dasturlash3
650-22 guruh: Abdumutalipov Shaxzodbek 7-raqam 1-masala: n elеmеntdаn tаshkil tоpgаn mаssiv bеrilgаn. Dаstlаb mаssiv elеmеntlаri оrаsidаn juftlаri indеkslаri o’sish tаrtibidа chiqаruvchi, kеyin mаssiv elеmеntlаri оrаsidаn tоqlаri kаmаyish tаrtibidа chiqаruvchi dаstur tuzing. Dasturi: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner k = new Scanner(System.in); int n = k.nextInt(); int mas[] = new int[n]; for (int i = 0 ;i mas[i]=k.nextInt(); } System.out.print("juftlari => "); for (int i = 0 ; i if (mas[i]%2==0) { System.out.print(mas[i]+" "); } } System.out.print(" \ntoqlari = > "); for (int i = 0;i if ((mas[i]-1)%2==0) { System.out.print(mas[i]+" "); } } } Natija: 2-masala: m х n o’lchаmli mаtritsа bеrilgаn. Mаtritsаning 2 gа kаrrаli (0, 2, 4, …) sаtrlаrini chiqаruvchi dаstur tuzing. Dasturi: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner k = new Scanner(System.in); int m = k.nextInt(); int n = k.nextInt(); int mas[][] = new int[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { System.out.print("matrisa["+i+"]["+j+"] = >"); mas[j][i] = k.nextInt(); } } for (int i= 0 ;i for (int j = 0 ;j if (mas[i][j]%2==0) { System.out.print(mas[i][j]+" "); } } } } } Natijasi: Download 118.92 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling