Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- import java.util.Random;
- class Main {
- public static void main(String[] args) {
- double x,y,xtemp,ytemp,granica,wynik;
- double dobre=0;
- double zle=0;
- int p=200;
- Random losuj = new Random();
- for(int i=0;i<p;i++){
- xtemp=losuj.nextInt(1000);
- ytemp=losuj.nextInt(1000);
- x=xtemp/1000;
- y=ytemp/1000;
- granica=Math.sqrt(x);
- if(y<=granica){
- dobre++;
- }
- else{
- zle++;
- }
- }
- System.out.println("Ilosc danych zawierajacych sie "+dobre);
- System.out.println("Ilosc danych niezawierajacych sie "+zle);
- wynik=dobre/p;
- System.out.println("Pole wynosi "+wynik);
- }
- }*/
- /*
- import java.util.Scanner;
- class Main{
- public static void main(String[] args){
- Scanner scanner= new Scanner(System.in);
- System.out.print("Podaj ktory wyraz ciagu obliczasz ");
- int k=scanner.nextInt();
- System.out.println(k+" -ty wyraz ciagu to " + ciag(k));
- }
- static int ciag(int n){
- if(n==1){
- return 1;
- }
- if(n==2){
- return 3;
- }
- else{
- return ciag(n-1) + ciag(n-2);
- }
- }
- }
- */
- /*
- import java.util.Scanner;
- class Main{
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- System.out.print("Podaj wyraz ciągu do obliczenia: ");
- int r=scanner.nextInt();
- int tab[] = new int[r+1];
- for(int i=1;i<=r;i++){
- if(i==1 || i==2){
- tab[i]=1;
- }
- else{
- if(i%3==0){
- tab[i]=2*tab[i-1];
- }
- if(i%3==1){
- tab[i]=(int) Math.pow(tab[i-2],2);
- }
- if(i%3==2){
- tab[i]=(int) Math.pow(2,tab[i-3]);
- }
- }
- }
- System.out.println(r+" -ty wyraz ciagu to "+tab[r]);
- }
- }
- */
- import java.util.Scanner;
- class Main{
- public static void main(String[] args){
- int[] wartosci = {500,200,100,50,20,10,5,2,1};
- int[] ilosci = {7,0,1,1,4,1,4,7,30};
- Scanner scanner = new Scanner(System.in);
- int zl;
- int gr;
- int o = 0;
- System.out.print("Podaj liczbe zl: ");
- zl=scanner.nextInt();
- System.out.print("Podaj liczbe gr: ");
- gr=scanner.nextInt();
- int reszta = (zl*100)+gr;
- int n = ilosci.length;
- while(reszta>0){
- if(reszta-wartosci[o]>=0){
- if(ilosci[o]>0){
- reszta=reszta-wartosci[o];
- if(wartosci[o]>=100){
- System.out.println("Wydano monete o wartosci: "+wartosci[o]/100+"zł");}
- else{
- System.out.println("Wydano monete o wartosci: "+wartosci[o]+"gr");
- }
- ilosci[o]=ilosci[o]-1;
- }
- else{
- o++;
- if(o>=n){
- System.out.println("Nie da sie wydac wiecej reszty."); break;
- }
- }
- }
- else{
- o++;
- if(o>=n){
- System.out.println("Nie da się wydać więcej reszty."); break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement