csakesz55

OOP_13_02_20

Feb 20th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package tombos;
  6.  
  7. import java.util.Scanner;
  8.  
  9. public class Tombos {
  10.  
  11.     public static void kiir(int[] k) {
  12.         for (int n : k) {
  13.             System.out.print(n + ", ");
  14.         }
  15.         System.out.println("--------");
  16.     }
  17.  
  18.     public static void kiir(int k, int[] tmb) {
  19.         System.out.print(k);
  20.         System.out.println(" -es indexen, " + tmb[k] + " értékkel");
  21.     }
  22.  
  23.     public static int[] csere(int max, int min) {
  24.         int[] cserelo = new int[2];
  25.         if (max < min) {
  26.             int temp = min;
  27.             min = max;
  28.             max = temp;
  29.         }
  30.         cserelo[0] = max;
  31.         cserelo[1] = min;
  32.         return cserelo;
  33.     }
  34.  
  35.     public static int[] general(int x, int y) {
  36.         int[] t = new int[100];
  37.         for (int i = 0; i < t.length; i++) {
  38.             t[i] = (int) (Math.random() * (x - y + 1) + y);
  39.         }
  40.         return t;
  41.  
  42.     }
  43.  
  44.     /*public static void legkis(int[] tmb, int x, int y){
  45.     int min = tmb[x];
  46.     int minindex = 0;
  47.     for (int i=x; i<y; i++){
  48.     if(tmb[i] < tmb[x]){
  49.     tmb[x] = tmb[i];
  50.     minindex = i;
  51.     }
  52.     }
  53.    
  54.     System.out.println("legkisebb elem: " + minindex + tmb[x]);
  55.     }*/
  56.     public static int minix(int[] tmb, int kezd, int veg) {
  57.         int ix = 0;
  58.         int min = tmb[kezd];
  59.         for(int i=kezd+1 ; i<=veg; i++){
  60.             if(min > tmb[i]){
  61.                 min = tmb[i];
  62.                 ix = i;
  63.             }
  64.         }
  65.         return ix;    
  66.     }
  67.  
  68.     public static void main(String[] args) {
  69.         System.out.println("Kerem a max erteket!");
  70.         Scanner read1 = new Scanner(System.in);
  71.         int x = read1.nextInt();
  72.  
  73.         System.out.println("Kerem a min erteket!");
  74.         Scanner read2 = new Scanner(System.in);
  75.         int y = read2.nextInt();
  76.  
  77.         /*int[] cserelt = csere(x, y);
  78.         int[] szamok = general(cserelt[0], cserelt[1]);
  79.         kiir(szamok);*/
  80.  
  81.         //kiir(general(csere(x, y)[0], csere(x, y)[1]));
  82.  
  83.         //legkis(szamok, 0, 10);
  84.        
  85.         int[] generaltSzamok = general(csere(x,y)[0], csere(x,y)[1]);
  86.         kiir(generaltSzamok);
  87.         kiir(minix(generaltSzamok, 0, 10), generaltSzamok);
  88.        
  89.         //minix(szamok, 0, 10);
  90.  
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment