Created
November 15, 2023 13:57
-
-
Save bytescreator/e975c1ca302e64c0ec735a3fa8278fe7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | |
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template | |
*/ | |
package cokboyutludizeler; | |
import java.util.Random; | |
import java.util.Scanner; | |
/** | |
* | |
* @author lenovo | |
*/ | |
public class CokBoyutluDizeler { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
System.out.println("Dize sayisini giriniz: "); | |
Scanner input = new Scanner(System.in); | |
int arrCnt = input.nextInt(); | |
int[] arrLens = new int[arrCnt]; | |
int[][] arrs = new int[arrCnt][]; | |
// jagged array | |
int total = 0; | |
for (int i = 0; i < arrCnt; i++) { | |
System.out.println(i + ". Dize eleman sayisini giriniz: "); | |
arrLens[i] = input.nextInt(); | |
arrs[i] = new int[arrLens[i]]; | |
total += arrLens[i]; | |
} | |
Random rnd = new Random(); | |
for (int i = 0; i < arrCnt; i++) { | |
for (int j = 0; j < arrLens[i]; j++) { | |
arrs[i][j] = rnd.nextInt(101); | |
System.out.println(i+". dizenin "+j+" elemani: " + arrs[i][j]); | |
} | |
} | |
int[] joiner = new int[total]; | |
int joinerCnt = 0; | |
int[] currArr = arrs[0]; | |
for (int j = 0; j < arrs.length; j++) { | |
for (int i = 0; i < arrs[j].length; i++) { | |
joiner[joinerCnt] = arrs[j][i]; | |
joinerCnt++; | |
} | |
} | |
for (int i = 0; i < joiner.length; i++) { | |
System.out.println(i+". eleman :"+joiner[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment