Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package tombos;
- import java.util.Scanner;
- public class Tombos {
- public static void kiir(int[] k) {
- for (int n : k) {
- System.out.print(n + ", ");
- }
- System.out.println("--------");
- }
- public static void kiir(int k, int[] tmb) {
- System.out.print(k);
- System.out.println(" -es indexen, " + tmb[k] + " értékkel");
- }
- public static int[] csere(int max, int min) {
- int[] cserelo = new int[2];
- if (max < min) {
- int temp = min;
- min = max;
- max = temp;
- }
- cserelo[0] = max;
- cserelo[1] = min;
- return cserelo;
- }
- public static int[] general(int x, int y) {
- int[] t = new int[100];
- for (int i = 0; i < t.length; i++) {
- t[i] = (int) (Math.random() * (x - y + 1) + y);
- }
- return t;
- }
- /*public static void legkis(int[] tmb, int x, int y){
- int min = tmb[x];
- int minindex = 0;
- for (int i=x; i<y; i++){
- if(tmb[i] < tmb[x]){
- tmb[x] = tmb[i];
- minindex = i;
- }
- }
- System.out.println("legkisebb elem: " + minindex + tmb[x]);
- }*/
- public static int minix(int[] tmb, int kezd, int veg) {
- int ix = 0;
- int min = tmb[kezd];
- for(int i=kezd+1 ; i<=veg; i++){
- if(min > tmb[i]){
- min = tmb[i];
- ix = i;
- }
- }
- return ix;
- }
- public static void main(String[] args) {
- System.out.println("Kerem a max erteket!");
- Scanner read1 = new Scanner(System.in);
- int x = read1.nextInt();
- System.out.println("Kerem a min erteket!");
- Scanner read2 = new Scanner(System.in);
- int y = read2.nextInt();
- /*int[] cserelt = csere(x, y);
- int[] szamok = general(cserelt[0], cserelt[1]);
- kiir(szamok);*/
- //kiir(general(csere(x, y)[0], csere(x, y)[1]));
- //legkis(szamok, 0, 10);
- int[] generaltSzamok = general(csere(x,y)[0], csere(x,y)[1]);
- kiir(generaltSzamok);
- kiir(minix(generaltSzamok, 0, 10), generaltSzamok);
- //minix(szamok, 0, 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment