Java

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.2 kB
1
Indexable
Never
package vezba;

import java.util.concurrent.atomic.AtomicInteger;

public class main {
	
	public static void Jun2023_7(int d) {
		int[][] mat = new int[2 * d][];
		
		for(int i = 0; i < 2 * d; i++) {
			if(i%2 == 0) {
				int len = (int)(Math.random() * 10) + 1;
				mat[i] = new int[1];
				mat[i][0] = len; 
			}
			else {
				mat[i] = new int[mat[i-1][0]];
				for(int j = 0; j< mat[i].length; j++) {
					mat[i][j] = (int)(Math.random() * d) + 1;
				}
			}
		}
		
		for(int i = 0; i < 2*d; i++) {
			for(int j = 0; j< mat[i].length; j++) {
				System.out.print(mat[i][j] + ", ");
			}
			System.out.println();
		}
	}
	
	enum FizickeVelicine{
		snaga("wat"),
		energija("jul");
		
		private final String jedinica;
		
		FizickeVelicine(String jedinica){
			this.jedinica = jedinica;
		}
		
		String jedinicaMere() {
			return this.jedinica;
		}
	}
	
	static void CifreRek(int n) {
		if(n == 0) return;
		System.out.print(n%10 + " ");
		CifreRek(n/10);
	}
	
	static void Cifre(int n) {
		while(n != 0) {
			System.out.print(n%10 + " ");
			n /= 10;
		}
	}
	
	interface Inter{
		void metoda();
	}
	
	class Prva implements Inter{

		@Override
		public void metoda() {
			// TODO Auto-generated method stub
		}
		
	}
	
	class Druga implements Inter{
		
		@Override
		public void metoda() {
			//TODO
		}
	}
	
	enum Elementi{
		prvi(), srednji(), zadnji();
		
		private int value;
		
		Elementi(){ this.value = 0;}
		
		void set(int v) {
			this.value = v;
		}
		
		int get() {
			return this.value;
		}
	}
	
	static void getElements(int[] a, Elementi prvi, Elementi srednji, Elementi zadnji) {
		prvi.set(a[0]);
		srednji.set(a[a.length/2]);
		zadnji.set(a[a.length-1]);
	}
	
	static void getElements(int[] a, int[] elements) {
		elements[0] = a[0];
		elements[1] = a[a.length/2];
		elements[2] = a[a.length - 1];
	}
	
	static void swap(AtomicInteger a, AtomicInteger b) {
		AtomicInteger pom = new AtomicInteger( a.get() );
		a.set(b.get());
		b.set(pom.get());
	}
	
	public static void main (String[] args) {
		//Jun2023_7(5);
		//FizickeVelicine snaga = FizickeVelicine.snaga;
		//System.out.println(snaga.jedinicaMere());
		//CifreRek(18683);
		//Cifre(18683);
		
		/*
		 * int n = 5; Inter[] arr = new Inter[n];
		 * 
		 * for (int i = 0; i < N; i++) { 
		 * if (i % 2 == 0) { 
		 * arr[i] = new Prva(); 
		 * } else {
		 * arr[i] = new Druga();
		 *  }
		 * }
		 */
		
		
		  Klasa k1 = new Klasa(); 
		  Klasa<Float> k2 = k1; 
		  Klasa<Double> k3 = new Klasa<>(1.1); 
		  Klasa k4 = k3; 
		  System.out.println(k4.getArg());
		 
		//int a[] = {1,2,3,4,5};
		//int[] elements = new int[3];
		//Elementi prvi = Elementi.prvi;
		//Elementi drugi = Elementi.srednji;
		//Elementi treci = Elementi.zadnji;
		
		//getElements(a,prvi,drugi,treci);
		//System.out.println(prvi.get() + " " + drugi.get() + " " + treci.get());
		
		//getElements(a, elements);
		//System.out.println(elements[0] + " " + elements[1] + " " + elements[2]);
		//AtomicInteger A = new AtomicInteger(4);
		//AtomicInteger B = new AtomicInteger(5);
		//swap(A,B);
		//System.out.print(A + " " + B);
	}
}