From 54bb132aaab755c62ae9d10e76a3b60fd86e8bd7 Mon Sep 17 00:00:00 2001 From: Matti Bos Date: Mon, 4 Dec 2023 15:01:50 +0000 Subject: [PATCH] Dateien nach "/" hochladen Fibonacci und 8 Damen --- Main.java | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 2 deletions(-) diff --git a/Main.java b/Main.java index 4e45b6f..6c38fce 100644 --- a/Main.java +++ b/Main.java @@ -1,6 +1,151 @@ +// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`, +// then press Enter. You can now see whitespace characters in your code. public class Main { - public static void main(String[] args) { - System.out.println("Brutaler Text der Beweis dafür ist, dass es geklappt hat"); + public static long Fibonacci_Iter(int num){ + long smol = 1; + long big = 1; + long temp; + while (1 < num){ + temp = smol; + smol = big; + big = big + temp; + num--; + } + return big; + } + public static long Fibonacci_Rec(int num){ + + // Inputqualität + if(num < 0){ + System.out.println("Ungültiger Input"); + return 0; + } + + if(num < 2){ + return 1; + } + + return Fibonacci_Rec(num-2) + Fibonacci_Rec(num-1); + } + public static long Fibonacci_Round(int num){ + long result = 1; + if(num==0 || num==1){return 1;} + for(int i=1; i= 0) { + field[row-col + i][i]=3; + } + + // Left 2 Right, Bottom 2 Top + if(row+i < 8 && row+i >=0 && col-i < 8 && col-i >=0){ + field[row+i][col-i]=3; + } + if(row-i < 8 && row-i >=0 && col+i < 8 && col+i >=0){ + field[row-i][col+i]=3; + } + } + // place queen + field[row][col]=1; + } + public static boolean QueensFree(int field[][], int row, int col){ + return field[row][col] == 0; + } + public static void QueensPrint(int field[][]){ + // print field + System.out.println("---------------"); + for(int i=0; i0){ + boolean full = true; + for(int i=0;i