Compare commits
	
		
			54 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					cd62170d1e | ||
| 
						 | 
					d33e33e64b | ||
| 
						 | 
					6ce134acd1 | ||
| f84eff9aa5 | |||
| 
						 | 
					5db6926f50 | ||
| 5344923baf | |||
| d76d58d382 | |||
| 
						 | 
					abc0cb0671 | ||
| 
						 | 
					4d10d38676 | ||
| 
						 | 
					e116fb4e42 | ||
| 
						 | 
					b8dd6e7ddb | ||
| 
						 | 
					aa32c0565a | ||
| 
						 | 
					1a4f0576a3 | ||
| 
						 | 
					11a6427c94 | ||
| 
						 | 
					e6855422d3 | ||
| 
						 | 
					e647fd6232 | ||
| 
						 | 
					4dba346f0c | ||
| 
						 | 
					dc829019bc | ||
| 
						 | 
					0da98417cd | ||
| be021d315f | |||
| 
						 | 
					9c2248ce76 | ||
| 
						 | 
					4ccc99dc7a | ||
| 
						 | 
					19447a7bdc | ||
| 
						 | 
					e946160920 | ||
| 
						 | 
					728ac1fe11 | ||
| 
						 | 
					360623916b | ||
| 
						 | 
					c23fe423e3 | ||
| 6fb9f329be | |||
| 
						 | 
					ad02c7106f | ||
| 879d2863af | |||
| 
						 | 
					d6a5564602 | ||
| 
						 | 
					d2aae461a0 | ||
| 
						 | 
					82a4b4e02b | ||
| 
						 | 
					57e4452cd1 | ||
| 
						 | 
					c09970c916 | ||
| 
						 | 
					8373a04747 | ||
| 
						 | 
					f10e7832a2 | ||
| 
						 | 
					dee7c90837 | ||
| 
						 | 
					cc2cf4aed6 | ||
| 
						 | 
					88e5d40db3 | ||
| 48bee0edc1 | |||
| 
						 | 
					091e66c85d | ||
| 
						 | 
					b89e6d7aba | ||
| 
						 | 
					68d4d99b59 | ||
| 
						 | 
					7a93be6d29 | ||
| 
						 | 
					873f940725 | ||
| 
						 | 
					e404159cbe | ||
| 
						 | 
					916ad84e18 | ||
| 
						 | 
					ad69a28c62 | ||
| 
						 | 
					f1ca9b4da6 | ||
| 
						 | 
					d38b65d59b | ||
| 
						 | 
					2cd7d780a9 | ||
| 
						 | 
					db56e1d635 | ||
| ae53688748 | 
							
								
								
									
										34
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								README.md
									
									
									
									
									
								
							@ -1 +1,33 @@
 | 
			
		||||
Hier entsteht der Photonics Helfer.
 | 
			
		||||
# Photonics Helfer
 | 
			
		||||
 | 
			
		||||
Ein hilfreiches Tool für Photoniker
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
--- 
 | 
			
		||||
## Anpassungen:
 | 
			
		||||
Um die Bedienung des Programms zu vereinfachen, wurden folgende Easter Eggs modifiziert:
 | 
			
		||||
- Bluescreen: wurde komplett deaktiviert
 | 
			
		||||
- Pfeiltasten: funktionieren ohne Passwort
 | 
			
		||||
- Bildschirmschoner: Die Aktivierungszeit wurde von 30s auf 60s erhöht.
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
### Linux
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
git clone https://gitea.fhgr.ch/zwickethomas/Photonics-Helfer
 | 
			
		||||
cd Photonics-Helfer
 | 
			
		||||
make
 | 
			
		||||
./Photonics-Helfer
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Windows
 | 
			
		||||
Im Ordner [Releses](https://gitea.fhgr.ch/zwickethomas/Photonics-Helfer/releases) ist das Programm als `.exe` verfügbar und kann einfach heruntergeladen werden.
 | 
			
		||||
 | 
			
		||||
#### Selbst kompilieren
 | 
			
		||||
Mit dem aktuellen Makefile ist dies mit dem CMD nicht möglich. Wer es trotzdem unter Windows kompilieren möchte kann dies mit [Cygwin](https://www.cygwin.com/) tun. (Bei der Installation ist noch zu beachten, dass das Paket `make` mitinstalliert werden muss.)
 | 
			
		||||
 | 
			
		||||
Alternativ kann man auch WSL (Windows Subsystem für Linux) verwenden. Eine Anleitung dazu gibt es hier: [WSL](https://learn.microsoft.com/de-de/windows/wsl/install) 
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								img/Photonics-Helfer-Menu.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								img/Photonics-Helfer-Menu.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 30 KiB  | 
							
								
								
									
										85
									
								
								makefile
									
									
									
									
									
								
							
							
						
						
									
										85
									
								
								makefile
									
									
									
									
									
								
							@ -1,71 +1,24 @@
 | 
			
		||||
CC = gcc
 | 
			
		||||
CPPFLAGS = -Iinclude -Isrc
 | 
			
		||||
CFLAGS = -Wall
 | 
			
		||||
LDLIBS = -lm
 | 
			
		||||
 | 
			
		||||
#### Start of system configuration section. ####
 | 
			
		||||
SRC = src
 | 
			
		||||
OBJ = obj
 | 
			
		||||
BIN = Photonics-Helfer
 | 
			
		||||
MKDIR = mkdir -p
 | 
			
		||||
SRCs := $(shell find $(SRC) -name "*.c")
 | 
			
		||||
OBJs := $(subst $(SRC), $(OBJ), $(SRCs:.c=.o))
 | 
			
		||||
 | 
			
		||||
VERSION := 2.00
 | 
			
		||||
CC      := gcc -O
 | 
			
		||||
CFLAGS  := -Wall -c
 | 
			
		||||
LDFLAGS := -g
 | 
			
		||||
LIBS = -lm
 | 
			
		||||
RM      := rm
 | 
			
		||||
all: $(BIN)
 | 
			
		||||
 | 
			
		||||
#### End of system configuration section. ####
 | 
			
		||||
$(BIN): $(OBJs)
 | 
			
		||||
	$(CC) $(CFLAGS) $(CPPFLAGS) $(OBJs) -o $@ $(LDLIBS)
 | 
			
		||||
 | 
			
		||||
.PHONY: all sort doc print clean
 | 
			
		||||
$(OBJs): $(SRCs)
 | 
			
		||||
	$(MKDIR) $(dir $@)
 | 
			
		||||
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst $(OBJ), $(SRC), $(@:.o=.c)) -o $@
 | 
			
		||||
 | 
			
		||||
# TARGET.exe
 | 
			
		||||
TARGET     = Photonics-Helfer
 | 
			
		||||
 | 
			
		||||
# Path for .c , .h and .o Files 
 | 
			
		||||
SRC_DIR = ./src/
 | 
			
		||||
OBJ_DIR = ./obj/
 | 
			
		||||
DOX_DIR = ./doc/doxygen/
 | 
			
		||||
 | 
			
		||||
# Files to compile
 | 
			
		||||
c_FILES := $(wildcard $(SRC_DIR)/*.c)
 | 
			
		||||
o_FILES := $(addprefix obj/,$(notdir $(c_FILES:.c=.o)))
 | 
			
		||||
 | 
			
		||||
#link all .o files
 | 
			
		||||
$(TARGET): $(o_FILES)
 | 
			
		||||
	@echo [CC] link: $<
 | 
			
		||||
	@$(CC) $(LDFLAGS) -o $@ $^
 | 
			
		||||
 | 
			
		||||
#compile all .c Files 
 | 
			
		||||
obj/%.o: src/%.c
 | 
			
		||||
	@echo [CC] compile: $<
 | 
			
		||||
	@$(CC) $(CFLAGS) -o $@ $<
 | 
			
		||||
	
 | 
			
		||||
#run TARGET.exe
 | 
			
		||||
run:
 | 
			
		||||
	$(TARGET)
 | 
			
		||||
	
 | 
			
		||||
#create folders and sort files
 | 
			
		||||
sort:
 | 
			
		||||
	@-mkdir src obj
 | 
			
		||||
	@-mv *.c *.h src
 | 
			
		||||
	@-mv *.o obj
 | 
			
		||||
	
 | 
			
		||||
#create folde "doc" then run doxygen
 | 
			
		||||
doc:
 | 
			
		||||
	@echo need to start RunDoxy.bat manually
 | 
			
		||||
#	@-mkdir doc
 | 
			
		||||
#	@call $(DOX_DIR)RunDoxy.bat
 | 
			
		||||
		
 | 
			
		||||
# Clean all the object files and the binary
 | 
			
		||||
clean:   
 | 
			
		||||
	@echo "[Cleaning]"
 | 
			
		||||
	@$(RM) -rfv $(OBJ_DIR)*
 | 
			
		||||
	@$(RM) -rfv $(TARGET).exe
 | 
			
		||||
 | 
			
		||||
help:
 | 
			
		||||
	@echo -e Version:   ' \t ' $(VERSION)
 | 
			
		||||
	@echo -e CC:       ' \t \t '  $(CC)
 | 
			
		||||
	@echo -e CFLAGS:   ' \t ' $(CFLAGS)
 | 
			
		||||
	@echo -e LDFLAGS:  ' \t ' $(LDFLAGS) ' \n ' 
 | 
			
		||||
	@echo    commands:
 | 
			
		||||
	@echo -e sort  ' \t \t ' sort files
 | 
			
		||||
	@echo -e run   ' \t \t ' run $(TARGET).exe
 | 
			
		||||
	@echo -e doc   ' \t \t ' run doxygen
 | 
			
		||||
	@echo -e clean ' \t \t ' clean all the .o
 | 
			
		||||
	@echo -e type make -help for more
 | 
			
		||||
	
 | 
			
		||||
		
 | 
			
		||||
clean:
 | 
			
		||||
	$(RM) -R $(BIN)
 | 
			
		||||
	$(RM) -R $(OBJ)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								questions.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								questions.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
Python/Numpy wurden speziell für den Unterricht an Schulen entwickelt. F
 | 
			
		||||
Python/Numpy ist die Abkürzung von “Numerical Python”. W
 | 
			
		||||
Python/Numpy ist eine Open-Source-Alternative von MATLAB. W
 | 
			
		||||
Python/Numpy ist ein CAS (Computer-Algebra-System). F
 | 
			
		||||
Die Kernkompetenzen von Python/Numpy sind Numerik, Datenverarbeitung und Datenvisualisierung. W
 | 
			
		||||
Python/Numpy ist für die gängigen Betriebssysteme Windows, Mac und Linux erhältlich. W
 | 
			
		||||
							
								
								
									
										413
									
								
								src/Fehlenden-vz/Fehlenden_Elektronik.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										413
									
								
								src/Fehlenden-vz/Fehlenden_Elektronik.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,413 @@
 | 
			
		||||
/* Elektronikhelper
 | 
			
		||||
Dieses Programm ist eine Unterstzützung in der Elektronik.
 | 
			
		||||
Es berechnet leichte rechnungsschritte.
 | 
			
		||||
Autor: Elena und Philip MR1 Semester
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 14.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 14.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Bibliothek
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
// Hilfsfunktionen
 | 
			
		||||
#define PI 3.141592653589793
 | 
			
		||||
#define BOLTZMANN 1.380649e-23
 | 
			
		||||
#define ELEMENTARLADUNG 1.602176634e-19
 | 
			
		||||
 | 
			
		||||
// Funktionen für Widerstandsberechnungen
 | 
			
		||||
void widerstand_berechnen() {
 | 
			
		||||
    double spannung, strom, widerstand;
 | 
			
		||||
    int auswahl;
 | 
			
		||||
    printf("\nWiderstandsberechnung (Ohmsches Gesetz):\n");
 | 
			
		||||
    printf("1. Widerstand berechnen\n");
 | 
			
		||||
    printf("2. Spannung berechnen\n");
 | 
			
		||||
    printf("3. Strom berechnen\n");
 | 
			
		||||
    printf("Wählen Sie eine Option: ");
 | 
			
		||||
    scanf("%d", &auswahl);
 | 
			
		||||
 | 
			
		||||
    switch (auswahl) {
 | 
			
		||||
        case 1:
 | 
			
		||||
            printf("Spannung (in Volt): ");
 | 
			
		||||
            scanf("%lf", &spannung);
 | 
			
		||||
            printf("Strom (in Ampere): ");
 | 
			
		||||
            scanf("%lf", &strom);
 | 
			
		||||
 | 
			
		||||
            if (strom != 0) {
 | 
			
		||||
                widerstand = spannung / strom;
 | 
			
		||||
                printf("Der Widerstand beträgt %.2f Ohm.\n", widerstand);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("Der Strom darf nicht null sein.\n");
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        case 2:
 | 
			
		||||
            printf("Widerstand (in Ohm): ");
 | 
			
		||||
            scanf("%lf", &widerstand);
 | 
			
		||||
            printf("Strom (in Ampere): ");
 | 
			
		||||
            scanf("%lf", &strom);
 | 
			
		||||
 | 
			
		||||
            if (widerstand > 0) {
 | 
			
		||||
                spannung = widerstand * strom;
 | 
			
		||||
                printf("Die Spannung beträgt %.2f Volt.\n", spannung);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("Der Widerstand muss größer als null sein.\n");
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        case 3:
 | 
			
		||||
            printf("Spannung (in Volt): ");
 | 
			
		||||
            scanf("%lf", &spannung);
 | 
			
		||||
            printf("Widerstand (in Ohm): ");
 | 
			
		||||
            scanf("%lf", &widerstand);
 | 
			
		||||
 | 
			
		||||
            if (widerstand > 0) {
 | 
			
		||||
                strom = spannung / widerstand;
 | 
			
		||||
                printf("Der Strom beträgt %.2f Ampere.\n", strom);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("Der Widerstand muss größer als null sein.\n");
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            printf("Ungültige Auswahl.\n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void parallelschaltung_berechnen() {
 | 
			
		||||
    int anzahl;
 | 
			
		||||
    double widerstand, gesamtwiderstand = 0;
 | 
			
		||||
    printf("\nParallelschaltung von Widerständen:\n");
 | 
			
		||||
    printf("Anzahl der Widerstände: ");
 | 
			
		||||
    scanf("%d", &anzahl);
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < anzahl; i++) {
 | 
			
		||||
        printf("Widerstand %d (in Ohm): ", i + 1);
 | 
			
		||||
        scanf("%lf", &widerstand);
 | 
			
		||||
        if (widerstand > 0) {
 | 
			
		||||
            gesamtwiderstand += 1 / widerstand;
 | 
			
		||||
        } else {
 | 
			
		||||
            printf("Ein Widerstand muss größer als null sein.\n");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (gesamtwiderstand > 0) {
 | 
			
		||||
        gesamtwiderstand = 1 / gesamtwiderstand;
 | 
			
		||||
        printf("Der Gesamtwiderstand der Parallelschaltung beträgt %.2f Ohm.\n", gesamtwiderstand);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void reihenschaltung_berechnen() {
 | 
			
		||||
    int anzahl;
 | 
			
		||||
    double widerstand, gesamtwiderstand = 0;
 | 
			
		||||
    printf("\nReihenschaltung von Widerständen:\n");
 | 
			
		||||
    printf("Anzahl der Widerstände: ");
 | 
			
		||||
    scanf("%d", &anzahl);
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < anzahl; i++) {
 | 
			
		||||
        printf("Widerstand %d (in Ohm): ", i + 1);
 | 
			
		||||
        scanf("%lf", &widerstand);
 | 
			
		||||
        if (widerstand > 0) {
 | 
			
		||||
            gesamtwiderstand += widerstand;
 | 
			
		||||
        } else {
 | 
			
		||||
            printf("Ein Widerstand muss größer als null sein.\n");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("Der Gesamtwiderstand der Reihenschaltung beträgt %.2f Ohm.\n", gesamtwiderstand);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void komplexe_schaltung_berechnen() {
 | 
			
		||||
    int anzahlReihen, anzahlParallel;
 | 
			
		||||
    double reihenWiderstand = 0, parallelWiderstand = 0, gesamtwiderstand = 0;
 | 
			
		||||
 | 
			
		||||
    printf("\nBerechnung komplexer Netzwerke:\n");
 | 
			
		||||
 | 
			
		||||
    // Reihenschaltung
 | 
			
		||||
    printf("Anzahl der Widerstände in der Reihenschaltung: ");
 | 
			
		||||
    scanf("%d", &anzahlReihen);
 | 
			
		||||
    for (int i = 0; i < anzahlReihen; i++) {
 | 
			
		||||
        double widerstand;
 | 
			
		||||
        printf("Widerstand %d (in Ohm): ", i + 1);
 | 
			
		||||
        scanf("%lf", &widerstand);
 | 
			
		||||
        if (widerstand > 0) {
 | 
			
		||||
            reihenWiderstand += widerstand;
 | 
			
		||||
        } else {
 | 
			
		||||
            printf("Ein Widerstand muss größer als null sein.\n");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Parallelschaltung
 | 
			
		||||
    printf("Anzahl der Widerstände in der Parallelschaltung: ");
 | 
			
		||||
    scanf("%d", &anzahlParallel);
 | 
			
		||||
    for (int i = 0; i < anzahlParallel; i++) {
 | 
			
		||||
        double widerstand;
 | 
			
		||||
        printf("Widerstand %d (in Ohm): ", i + 1);
 | 
			
		||||
        scanf("%lf", &widerstand);
 | 
			
		||||
        if (widerstand > 0) {
 | 
			
		||||
            parallelWiderstand += 1 / widerstand;
 | 
			
		||||
        } else {
 | 
			
		||||
            printf("Ein Widerstand muss größer als null sein.\n");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (parallelWiderstand > 0) {
 | 
			
		||||
        parallelWiderstand = 1 / parallelWiderstand;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Gesamtwiderstand
 | 
			
		||||
    gesamtwiderstand = reihenWiderstand + parallelWiderstand;
 | 
			
		||||
    printf("Der Gesamtwiderstand des Netzwerks beträgt %.2f Ohm.\n", gesamtwiderstand);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Spannungsteiler-Funktion
 | 
			
		||||
void spannungsteiler_berechnen() {
 | 
			
		||||
    int anzahl;
 | 
			
		||||
    double vin, vout, gesamtwiderstand = 0;
 | 
			
		||||
    printf("\nSpannungsteiler-Berechnung:\n");
 | 
			
		||||
    printf("Anzahl der Widerstände im Spannungsteiler: ");
 | 
			
		||||
    scanf("%d", &anzahl);
 | 
			
		||||
 | 
			
		||||
    double widerstaende[anzahl];
 | 
			
		||||
    for (int i = 0; i < anzahl; i++) {
 | 
			
		||||
        printf("Widerstand R%d (in Ohm): ", i + 1);
 | 
			
		||||
        scanf("%lf", &widerstaende[i]);
 | 
			
		||||
        gesamtwiderstand += widerstaende[i];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("Eingangsspannung Vin (in Volt): ");
 | 
			
		||||
    scanf("%lf", &vin);
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < anzahl; i++) {
 | 
			
		||||
        vout = vin * (widerstaende[i] / gesamtwiderstand);
 | 
			
		||||
        printf("Spannung über R%d beträgt %.2f Volt.\n", i + 1, vout);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Leistungsberechnung
 | 
			
		||||
void leistung_berechnen() {
 | 
			
		||||
    double spannung, strom, leistung;
 | 
			
		||||
    int auswahl;
 | 
			
		||||
    printf("\nLeistungsberechnung:\n");
 | 
			
		||||
    printf("1. Leistung berechnen (benötigt Spannung und Strom)\n");
 | 
			
		||||
    printf("2. Spannung berechnen (benötigt Leistung und Strom)\n");
 | 
			
		||||
    printf("3. Strom berechnen (benötigt Leistung und Spannung)\n");
 | 
			
		||||
    printf("Wählen Sie eine Option: ");
 | 
			
		||||
    scanf("%d", &auswahl);
 | 
			
		||||
 | 
			
		||||
    switch (auswahl) {
 | 
			
		||||
        case 1:
 | 
			
		||||
            printf("Spannung (in Volt): ");
 | 
			
		||||
            scanf("%lf", &spannung);
 | 
			
		||||
            printf("Strom (in Ampere): ");
 | 
			
		||||
            scanf("%lf", &strom);
 | 
			
		||||
 | 
			
		||||
            leistung = spannung * strom;
 | 
			
		||||
            printf("Die Leistung beträgt %.2f Watt.\n", leistung);
 | 
			
		||||
            break;
 | 
			
		||||
        case 2:
 | 
			
		||||
            printf("Leistung (in Watt): ");
 | 
			
		||||
            scanf("%lf", &leistung);
 | 
			
		||||
            printf("Strom (in Ampere): ");
 | 
			
		||||
            scanf("%lf", &strom);
 | 
			
		||||
 | 
			
		||||
            if (strom > 0) {
 | 
			
		||||
                spannung = leistung / strom;
 | 
			
		||||
                printf("Die Spannung beträgt %.2f Volt.\n", spannung);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("Der Strom muss größer als null sein.\n");
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        case 3:
 | 
			
		||||
            printf("Leistung (in Watt): ");
 | 
			
		||||
            scanf("%lf", &leistung);
 | 
			
		||||
            printf("Spannung (in Volt): ");
 | 
			
		||||
            scanf("%lf", &spannung);
 | 
			
		||||
 | 
			
		||||
            if (spannung > 0) {
 | 
			
		||||
                strom = leistung / spannung;
 | 
			
		||||
                printf("Der Strom beträgt %.2f Ampere.\n", strom);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("Die Spannung muss größer als null sein.\n");
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            printf("Ungültige Auswahl.\n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Weitere Funktionen (Dioden, Transistoren, Kondensatoren, LEDs, Knoten-/Maschenregel)
 | 
			
		||||
void dioden_berechnen() {
 | 
			
		||||
    double temperatur, schwellenspannung, is, strom;
 | 
			
		||||
    printf("\nDioden-Berechnung:\n");
 | 
			
		||||
    printf("Geben Sie die Temperatur (in Kelvin) ein: ");
 | 
			
		||||
    scanf("%lf", &temperatur);
 | 
			
		||||
    printf("Geben Sie den Sättigungsstrom Is (in Ampere) ein: ");
 | 
			
		||||
    scanf("%lf", &is);
 | 
			
		||||
    printf("Geben Sie die Schwellenspannung der Diode (in Volt) ein: ");
 | 
			
		||||
    scanf("%lf", &schwellenspannung);
 | 
			
		||||
 | 
			
		||||
    double vt = (BOLTZMANN * temperatur) / ELEMENTARLADUNG;
 | 
			
		||||
    strom = is * (exp(schwellenspannung / vt) - 1);
 | 
			
		||||
    printf("Der Strom durch die Diode beträgt %.6f Ampere.\n", strom);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void transistor_berechnen() {
 | 
			
		||||
    double verstaerkung, basisstrom, kollektorstrom, saettigungsspannung;
 | 
			
		||||
    printf("\nTransistor-Berechnung:\n");
 | 
			
		||||
    printf("Verstärkungsfaktor (hFE): ");
 | 
			
		||||
    scanf("%lf", &verstaerkung);
 | 
			
		||||
    printf("Basisstrom (in Ampere): ");
 | 
			
		||||
    scanf("%lf", &basisstrom);
 | 
			
		||||
 | 
			
		||||
    kollektorstrom = verstaerkung * basisstrom;
 | 
			
		||||
    printf("Der Kollektorstrom beträgt %.6f Ampere.\n", kollektorstrom);
 | 
			
		||||
 | 
			
		||||
    printf("Sättigungsspannung (in Volt): ");
 | 
			
		||||
    scanf("%lf", &saettigungsspannung);
 | 
			
		||||
    printf("Die Sättigungsspannung beträgt %.2f Volt.\n", saettigungsspannung);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void kondensator_berechnen() {
 | 
			
		||||
    double kapazitaet, spannung, energie, zeit, widerstand;
 | 
			
		||||
    printf("\nKondensator-Berechnung:\n");
 | 
			
		||||
    printf("kapazität (in Farad): ");
 | 
			
		||||
    scanf("%lf", &kapazitaet);
 | 
			
		||||
    printf("Spannung (in Volt): ");
 | 
			
		||||
    scanf("%lf", &spannung);
 | 
			
		||||
 | 
			
		||||
    energie = 0.5 * kapazitaet * pow(spannung, 2);
 | 
			
		||||
    printf("Die Energie im Kondensator beträgt %.6f Joule.\n", energie);
 | 
			
		||||
 | 
			
		||||
    printf("Entladezeit berechnen? (1 für Ja, 0 für Nein): ");
 | 
			
		||||
    int wahl;
 | 
			
		||||
    scanf("%d", &wahl);
 | 
			
		||||
 | 
			
		||||
    if (wahl == 1) {
 | 
			
		||||
        printf("Widerstand (in Ohm): ");
 | 
			
		||||
        scanf("%lf", &widerstand);
 | 
			
		||||
        zeit = kapazitaet * widerstand;
 | 
			
		||||
        printf("Die Zeitkonstante betraegt %.2f Sekunden.\n", zeit);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void led_vorwiderstand_berechnen() {
 | 
			
		||||
    double betriebsspannung, durchlassspannung, strom, vorwiderstand, verlustleistung;
 | 
			
		||||
    printf("\nLED-Vorwiderstandsberechnung:\n");
 | 
			
		||||
    printf("Betriebsspannung (in Volt): ");
 | 
			
		||||
    scanf("%lf", &betriebsspannung);
 | 
			
		||||
    printf("Durchlassspannung der LED (in Volt): ");
 | 
			
		||||
    scanf("%lf", &durchlassspannung);
 | 
			
		||||
    printf("Strom durch die LED (in Ampere): ");
 | 
			
		||||
    scanf("%lf", &strom);
 | 
			
		||||
 | 
			
		||||
    vorwiderstand = (betriebsspannung - durchlassspannung) / strom;
 | 
			
		||||
    verlustleistung = pow((betriebsspannung - durchlassspannung), 2) / vorwiderstand;
 | 
			
		||||
 | 
			
		||||
    printf("Der Vorwiderstand beträgt %.2f Ohm.\n", vorwiderstand);
 | 
			
		||||
    printf("Die maximale Verlustleistung des Widerstands beträgt %.2f Watt.\n", verlustleistung);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void knotenregel_berechnen() {
 | 
			
		||||
    int n;  // Anzahl der Ströme und Spannungen
 | 
			
		||||
    float sum_current = 0.0, current;
 | 
			
		||||
 | 
			
		||||
    // Knotenregel: Ströme berechnen
 | 
			
		||||
    printf("Geben Sie die Anzahl der Stroeme ein im Knoten: ");
 | 
			
		||||
    scanf("%d", &n);
 | 
			
		||||
 | 
			
		||||
    printf("Geben Sie die Stroeme ein (in Ampere):\n");
 | 
			
		||||
    for (int i = 1; i <= n; i++) {
 | 
			
		||||
        printf("Strom %d: ", i);
 | 
			
		||||
        scanf("%f", ¤t);
 | 
			
		||||
        sum_current += current;  // Ströme addieren
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("\nSumme der Ströme: %.2f A\n", sum_current);
 | 
			
		||||
    if (sum_current == 0) {
 | 
			
		||||
        printf("Der Knoten erfüllt die Knotenregel (Summe der Ströme ist null).\n");
 | 
			
		||||
    } else {
 | 
			
		||||
        printf("Der Knoten erfüllt die Knotenregel nicht (Summe der Ströme ist %.2f).\n", sum_current);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void maschenregel_berechnen() {
 | 
			
		||||
    int n;  // Anzahl der Ströme und Spannungen
 | 
			
		||||
    float sum_voltage = 0.0, voltage;
 | 
			
		||||
    // Maschenregel: Spannungen berechnen
 | 
			
		||||
    printf("\nGeben Sie die Anzahl der Spannungen in einer Masche ein: ");
 | 
			
		||||
    scanf("%d", &n);
 | 
			
		||||
 | 
			
		||||
    printf("Geben Sie die Spannungen ein (in Volt):\n");
 | 
			
		||||
    for (int i = 1; i <= n; i++) {
 | 
			
		||||
        printf("Spannung %d: ", i);
 | 
			
		||||
        scanf("%f", &voltage);
 | 
			
		||||
        sum_voltage += voltage;  // Spannungen addieren
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Überprüfung der Maschenregel
 | 
			
		||||
    printf("\nSumme der Spannungen: %.2f V\n", sum_voltage);
 | 
			
		||||
    if (sum_voltage == 0) {
 | 
			
		||||
        printf("Die Masche erfüllt die Maschenregel (Summe der Spannungen ist null).\n");
 | 
			
		||||
    } else {
 | 
			
		||||
        printf("Die Masche erfüllt die Maschenregel nicht (Summe der Spannungen ist %.2f).\n", sum_voltage);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Fehlenden_Elektronik_main() {
 | 
			
		||||
    char auswahl[21] = {0};
 | 
			
		||||
    long auswahl_int = 0;
 | 
			
		||||
    char *endptr;
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        printf("\nElektronik-Berechnungstool:\n");
 | 
			
		||||
        printf("1. Widerstandsberechnung (Ohmsches Gesetz)\n");
 | 
			
		||||
        printf("2. Parallelschaltung von Widerständen\n");
 | 
			
		||||
        printf("3. Reihenschaltung von Widerständen\n");
 | 
			
		||||
        printf("4. Komplexe Netzwerke\n");
 | 
			
		||||
        printf("5. Spannungsteiler\n");
 | 
			
		||||
        printf("6. Leistungsberechnung\n");
 | 
			
		||||
        printf("7. Dioden-Berechnung\n");
 | 
			
		||||
        printf("8. Transistor-Berechnung\n");
 | 
			
		||||
        printf("9. Kondensator-Berechnung\n");
 | 
			
		||||
        printf("10. LED-Vorwiderstandsberechnung\n");
 | 
			
		||||
        printf("11. Knotenregel-Berechnung\n");
 | 
			
		||||
        printf("12. Maschenregel-Berechnung\n");
 | 
			
		||||
        printf("0. Beenden\n");
 | 
			
		||||
        printf("Wählen Sie eine Option: ");
 | 
			
		||||
        scanf("%20s", auswahl);
 | 
			
		||||
        auswahl_int = strtol((const char*)auswahl, &endptr, 10);
 | 
			
		||||
 | 
			
		||||
        if (*endptr != 0){
 | 
			
		||||
            auswahl_int = -1;
 | 
			
		||||
        }
 | 
			
		||||
        if (*endptr == 'q'){
 | 
			
		||||
        return 10;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (auswahl_int) {
 | 
			
		||||
            case 1: widerstand_berechnen(); break;
 | 
			
		||||
            case 2: parallelschaltung_berechnen(); break;
 | 
			
		||||
            case 3: reihenschaltung_berechnen(); break;
 | 
			
		||||
            case 4: komplexe_schaltung_berechnen(); break;
 | 
			
		||||
            case 5: spannungsteiler_berechnen(); break;
 | 
			
		||||
            case 6: leistung_berechnen(); break;
 | 
			
		||||
            case 7: dioden_berechnen(); break;
 | 
			
		||||
            case 8: transistor_berechnen(); break;
 | 
			
		||||
            case 9: kondensator_berechnen(); break;
 | 
			
		||||
            case 10: led_vorwiderstand_berechnen(); break;
 | 
			
		||||
            case 11: knotenregel_berechnen(); break;
 | 
			
		||||
            case 12: maschenregel_berechnen(); break;
 | 
			
		||||
            case 0: printf("Programm beendet.\n"); break;
 | 
			
		||||
            default: printf("Ungültige Auswahl.\n");
 | 
			
		||||
        }
 | 
			
		||||
    } while (auswahl_int != 0);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								src/Fehlenden-vz/Fehlenden_Elektronik.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/Fehlenden-vz/Fehlenden_Elektronik.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
#ifndef Fehlenden_Elektronik_H_ 
 | 
			
		||||
#define Fehlenden_Elektronik_H_ 
 | 
			
		||||
 | 
			
		||||
// #ifndef _FILE_NAME_H_ 
 | 
			
		||||
// #define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
   int Fehlenden_Elektronik_main();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										206
									
								
								src/Flugi-tz/Funktion_Flugi.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								src/Flugi-tz/Funktion_Flugi.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,206 @@
 | 
			
		||||
#include "Funktion_Flugi.h"
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int quiz(char Question[][500], char Answer[], int zahl_h) {
 | 
			
		||||
    char repeat[zahl_h][500]; // Array, um falsche Fragen zu speichern
 | 
			
		||||
    char userAnswer;
 | 
			
		||||
    int incorrectIndices[zahl_h]; // Indizes der falschen Antworten
 | 
			
		||||
    int incorrectCount = 0;  // Anzahl falscher Antworten 
 | 
			
		||||
    srand(time(NULL)); //SL Zufallsgenerator initialisieren                  
 | 
			
		||||
 | 
			
		||||
    int zufallszahl = 0;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    // Fragen durchgehen und Antworten überprüfen
 | 
			
		||||
    for (i = 0; i < zahl_h; i++) 
 | 
			
		||||
    {
 | 
			
		||||
        zufallszahl = rand() % zahl_h  ; // SL % 2 räpresentier die Obergrenze
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        printf("Frage %d: %s\n", i + 1, Question[zufallszahl]);//SL Zufallszahl durch i ersetzt
 | 
			
		||||
        scanf(" %c", &userAnswer); // wichtig lehrschlag vor %c
 | 
			
		||||
 | 
			
		||||
        if (userAnswer == Answer[zufallszahl]) {
 | 
			
		||||
            printf("Korrekt!\n");
 | 
			
		||||
        } 
 | 
			
		||||
        else if (userAnswer != Answer[zufallszahl])
 | 
			
		||||
        {
 | 
			
		||||
            printf("Falsch!\n");
 | 
			
		||||
            strcpy(repeat[incorrectCount], Question[i]); // Frage speichern
 | 
			
		||||
            incorrectIndices[incorrectCount] = zufallszahl;        // Index speichern
 | 
			
		||||
            incorrectCount++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Überprüfen, ob es falsche Antworten gibt
 | 
			
		||||
    if (incorrectCount > 0) {
 | 
			
		||||
        char retry;
 | 
			
		||||
        printf("Du hast %d falsche Antworten. Willst du diese wiederholen? (j/n): ", incorrectCount);
 | 
			
		||||
        scanf(" %c", &retry);
 | 
			
		||||
 | 
			
		||||
        if (retry == 'j' || retry == 'J') {
 | 
			
		||||
            for (int i = 0; i < incorrectCount; i++) {
 | 
			
		||||
                printf("Wiederholung: %s\n", repeat[i]);
 | 
			
		||||
                scanf(" %c", &userAnswer);
 | 
			
		||||
 | 
			
		||||
                if (userAnswer == Answer[incorrectIndices[i]]) {
 | 
			
		||||
                    printf("Jetzt korrekt!\n");
 | 
			
		||||
                } else {
 | 
			
		||||
                    printf("Immer noch falsch.\n");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        printf("Alle Antworten waren korrekt!\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return incorrectCount;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Funktion: Baum zeichnen
 | 
			
		||||
void draw_tree(int total , int wrong) {
 | 
			
		||||
    total++;
 | 
			
		||||
    for (int i = 0; i < total - 1; i++) {
 | 
			
		||||
        // Sterne einrücken
 | 
			
		||||
        for (int j = 0; j < total - i - 1; j++) {
 | 
			
		||||
            printf(" ");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Sterne für diese Ebene zeichnen
 | 
			
		||||
        for (int y = 0; y < (2 * i + 1); y++) {
 | 
			
		||||
            if (wrong == 0 && i == 0) {
 | 
			
		||||
                // Besondere goldene Spitze, wenn alles richtig ist
 | 
			
		||||
                printf("\033[1;33m*\033[0m");
 | 
			
		||||
            } else if (i < wrong) {
 | 
			
		||||
                // Ebene gehört zu den falschen Fragen (Rot)
 | 
			
		||||
                printf("\033[1;31m*\033[0m"); // Rote Sterne
 | 
			
		||||
            } else {
 | 
			
		||||
                // Ebene gehört zu den richtigen Fragen (Grün)
 | 
			
		||||
                printf("\033[1;32m*\033[0m"); // Grüne Sterne
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        printf("\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Stamm zentrieren
 | 
			
		||||
    for (int i = 0; i < total - 1; i++) {
 | 
			
		||||
        printf(" ");
 | 
			
		||||
    }
 | 
			
		||||
    printf("|\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Funktion: Ergebnisse ausgeben
 | 
			
		||||
void print_results(int total, int wrong) {
 | 
			
		||||
    printf("\n=== Ergebnis der Auswertung ===\n");
 | 
			
		||||
    printf("Gesamtfragen: %d\n", total);
 | 
			
		||||
    printf("Falsche Fragen: %d\n", wrong);
 | 
			
		||||
    printf("Richtige Fragen: %d\n", total - wrong);
 | 
			
		||||
 | 
			
		||||
    // Besondere Nachricht, wenn alles richtig ist
 | 
			
		||||
    if (wrong == 0) {
 | 
			
		||||
        printf("\n Perfekt gemacht! Alle Fragen richtig beantwortet! \n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Hauptfunktion
 | 
			
		||||
int Flugi() {
 | 
			
		||||
    int zahl_h ; // Höhe des Baumes (Gesamtfragen)
 | 
			
		||||
    int wrong_questions; // Anzahl der falschen Fragen
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    FILE *file;                             // File-Pointer
 | 
			
		||||
    char filename[50] = "questions.txt" ;   // Filename
 | 
			
		||||
    int MaxLines = 500;
 | 
			
		||||
    int MaxLength = 500;
 | 
			
		||||
    char lines[MaxLines][MaxLength];        // Array for separate lines
 | 
			
		||||
    int line_count = 0;                     // Counter for number of lines
 | 
			
		||||
 | 
			
		||||
    char Question[MaxLines][MaxLength];     // Array for questions
 | 
			
		||||
    char Answer[MaxLines];                  // Array for answer
 | 
			
		||||
    int qst = 0;
 | 
			
		||||
    int len = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Open file
 | 
			
		||||
    file = fopen(filename, "r");
 | 
			
		||||
    if (file == NULL) {
 | 
			
		||||
        printf("Fehler: Datei \"%s\" konnte nicht geöffnet werden.\n", filename);
 | 
			
		||||
        return 1; // End program if file can't be opened
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Read lines from the file
 | 
			
		||||
    while (fgets(lines[line_count], MaxLength, file) != NULL) {
 | 
			
		||||
        size_t len = strlen(lines[line_count]);
 | 
			
		||||
        if (len <= 0){
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #ifdef _WIN32
 | 
			
		||||
            if (lines[line_count][len - 1] == '\n') {
 | 
			
		||||
                lines[line_count][len - 1] = '\0'; // Entferne das '\n'
 | 
			
		||||
                len--; 
 | 
			
		||||
            }
 | 
			
		||||
        #else
 | 
			
		||||
            if (lines[line_count][len - 1] == '\n') {
 | 
			
		||||
                lines[line_count][len - 1] = '\0'; // Entferne das '\n'
 | 
			
		||||
                len -= 3; 
 | 
			
		||||
            } else {
 | 
			
		||||
                len -= 1;
 | 
			
		||||
            }
 | 
			
		||||
        #endif
 | 
			
		||||
 | 
			
		||||
        // Frage und Antwort trennen
 | 
			
		||||
        if (1) { 
 | 
			
		||||
            Answer[line_count] = lines[line_count][len]; // Letztes Zeichen als Antwort
 | 
			
		||||
            lines[line_count][len - 2] = '\0';              // Kürze Frage um Antwortzeichen
 | 
			
		||||
            strcpy(Question[line_count], lines[line_count]);
 | 
			
		||||
        }
 | 
			
		||||
        line_count++;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    zahl_h = line_count;
 | 
			
		||||
 | 
			
		||||
    // close file
 | 
			
		||||
    fclose(file);
 | 
			
		||||
 | 
			
		||||
    if (0){
 | 
			
		||||
        // Output
 | 
			
		||||
        printf("\nDie Datei wurde in %d Zeilen eingelesen:\n", line_count);
 | 
			
		||||
        for (int i = 0; i < line_count; i++) {
 | 
			
		||||
            printf("Zeile %d: %s\n", i + 1, Question[i]);
 | 
			
		||||
            size_t len = strlen(lines[i]);
 | 
			
		||||
            printf("Antwort: %c\n", Answer[i]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //char question[2][50]; //= {"Schaffen wir das? (1 = Ja, 0 = Nein)", "Wie geht das? (1 = Einfach, 0 = Schwer)"};
 | 
			
		||||
    //int answer[2] = {1, 0};
 | 
			
		||||
 | 
			
		||||
    // Eingabebefehl
 | 
			
		||||
    printf("Für wahre Aussage: W, für falsch Ausage: F\n");
 | 
			
		||||
 | 
			
		||||
    int incorrectCount = quiz(Question, Answer, zahl_h);
 | 
			
		||||
    printf("Anzahl falscher Antworten: %d\n", incorrectCount);
 | 
			
		||||
 | 
			
		||||
    wrong_questions = incorrectCount;
 | 
			
		||||
 | 
			
		||||
    // Baum zeichnen
 | 
			
		||||
    draw_tree(zahl_h, wrong_questions);
 | 
			
		||||
 | 
			
		||||
    // Ergebnisse ausgeben
 | 
			
		||||
    print_results(zahl_h, wrong_questions);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    usleep(2000000);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    Flugi();
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
							
								
								
									
										30
									
								
								src/Flugi-tz/Funktion_Flugi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/Flugi-tz/Funktion_Flugi.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
/* Funktion_Flugi.h
 | 
			
		||||
 | 
			
		||||
Autor: Simon Sommer, Simon Ladner, Lucas Defuns, Delia Schmid
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 16.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 16.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef Funktion_Flugi_H
 | 
			
		||||
#define Funktion_Flugi_H
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
// Konstanten für die Dateiverwaltung
 | 
			
		||||
#define MAX_LINES 500
 | 
			
		||||
#define MAX_LENGTH 500
 | 
			
		||||
 | 
			
		||||
// Funktionsprototypen
 | 
			
		||||
int quiz(char Question[][MAX_LENGTH], char Answer[], int zahl_h);
 | 
			
		||||
void draw_tree(int total, int wrong);
 | 
			
		||||
void print_results(int total, int wrong);
 | 
			
		||||
 | 
			
		||||
int Flugi();
 | 
			
		||||
 | 
			
		||||
#endif // QUIZ_H
 | 
			
		||||
							
								
								
									
										148
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,148 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
// Funktion, um einen String in Kleinbuchstaben umzuwandeln
 | 
			
		||||
void zuKleinbuchstaben(char* str) {
 | 
			
		||||
    for (int i = 0; str[i]; i++) {
 | 
			
		||||
        str[i] = tolower(str[i]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Funktion, um die Wellenlänge einer Farbe auszugeben
 | 
			
		||||
int value = 0;
 | 
			
		||||
int failcount = 0;
 | 
			
		||||
int returncode = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int Wellenlaenge(const char* color) {
 | 
			
		||||
    if (strcmp(color, "rot") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von rotem Licht liegt im Bereich zwischen 620 und 750 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "orange") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von orangem Licht liegt im Bereich zwischen 590 und 620 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "gelb") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von gelbem Licht liegt im Bereich zwischen 570 und 590 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "grün") == 0 || strcmp(color, "gruen") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von grünem Licht liegt im Bereich zwischen 495 und 570 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "blau") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von blauem Licht liegt im Bereich zwischen 450 und 495 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "violett") == 0) {
 | 
			
		||||
        printf("Die Wellenlänge von violettem Licht liegt im Bereich zwischen 380 und 450 nm.\n");
 | 
			
		||||
    } else if (strcmp(color, "q") == 0) {
 | 
			
		||||
        return 10;
 | 
			
		||||
    } else if (failcount >= 5) {
 | 
			
		||||
        return 20;
 | 
			
		||||
    } else {
 | 
			
		||||
        printf("Oh nein! Diese Farbe kenne ich nicht. Bitte geben sie eine der 6 Grund- oder Komplementärfarben ein.\n");
 | 
			
		||||
    }
 | 
			
		||||
    failcount++;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Funktion, um die Farbe einer Wellenlänge auszugeben
 | 
			
		||||
int wavelength = 0;
 | 
			
		||||
 | 
			
		||||
void printColor(int wavelength) {
 | 
			
		||||
    if (wavelength < 0){
 | 
			
		||||
        printf("Ich mag keine negativen Zahlen. Bitte eine positive Zahl eingeben!\n");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    switch (wavelength) {
 | 
			
		||||
        case 620 ... 750: // Bereich von rotem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Rot\n");
 | 
			
		||||
            break;
 | 
			
		||||
        case 590 ... 619: // Bereich von orangem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Orange\n");
 | 
			
		||||
            break;
 | 
			
		||||
        case 570 ... 589: // Bereich von gelbem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Gelb\n");
 | 
			
		||||
            break;
 | 
			
		||||
        case 495 ... 569: // Bereich von grünem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Grün\n");
 | 
			
		||||
            break;
 | 
			
		||||
        case 450 ... 494: // Bereich von blauem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Blau\n");
 | 
			
		||||
            break;
 | 
			
		||||
        case 380 ... 449: // Bereich von violettem Licht
 | 
			
		||||
            printf("Das Licht dieser Wellenlänge ist Violett\n");
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        // nicht sichtbarer Bereich
 | 
			
		||||
        case 0 ... 379:
 | 
			
		||||
            printf("Diese Wellenlänge ist kürzer/kleiner als der Bereich des sichtbaren Lichts\n");
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            printf("Diese Wellenlänge ist länger/grösser als der Bereich des sichtbaren Lichts\n");
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Main Programm
 | 
			
		||||
int Wellenlaengen_rechner_main() {
 | 
			
		||||
 | 
			
		||||
    printf("Guten Tag.\nSie mögen Farben? Dann sind Sie hier genau richtig, denn ich zeige Ihnen den Zusammenhang zwischen der Wellenlänge und der Farbe von Licht.\n");
 | 
			
		||||
    int modus = 0;
 | 
			
		||||
    int failcount = 0;
 | 
			
		||||
    int returncode = 0;
 | 
			
		||||
 | 
			
		||||
    char auswahl[21] = {0};
 | 
			
		||||
    long wavelength = 0;
 | 
			
		||||
    char *endptr;
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
        printf("\nFalls Sie die Lichtfarbe des emittierten Lichtes erfahren wollen, drücken Sie die Taste 1. Wenn Sie die Wellenlänge einer bestimmten Lichtfarbe interessiert, drücken Sie die Taste 2.\n");
 | 
			
		||||
 | 
			
		||||
        scanf("%20s", auswahl);
 | 
			
		||||
        modus = strtol((const char*)auswahl, &endptr, 10);
 | 
			
		||||
 | 
			
		||||
        if (*endptr != 0){
 | 
			
		||||
            modus = -1;
 | 
			
		||||
        }
 | 
			
		||||
        if (*endptr == 'q'){
 | 
			
		||||
            return 10;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Ausgabe der Farbe
 | 
			
		||||
        if (modus==1) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            printf("Bitte geben Sie eine Wellenlänge ein (in nm): ");
 | 
			
		||||
            scanf("%20s", auswahl);
 | 
			
		||||
            wavelength = strtol((const char*)auswahl, &endptr, 10);
 | 
			
		||||
 | 
			
		||||
            if (*endptr != 0){
 | 
			
		||||
                wavelength = -1;
 | 
			
		||||
            }
 | 
			
		||||
            if (*endptr == 'q'){
 | 
			
		||||
                return 10;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            printColor(wavelength);
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        //Ausgabe der Wellenlänge
 | 
			
		||||
        else if (modus==2) {
 | 
			
		||||
 | 
			
		||||
            char color[50];
 | 
			
		||||
 | 
			
		||||
            printf("Bitte geben Sie eine Farbe ein (z. B. Rot, Orange, Gelb, Grün, Blau, Violett): ");
 | 
			
		||||
            scanf("%49s", color);
 | 
			
		||||
 | 
			
		||||
            // Funktion für Eingabe in Kleinbuchstaben umwandeln abrufen
 | 
			
		||||
            zuKleinbuchstaben(color);
 | 
			
		||||
 | 
			
		||||
            // Funktion für Ausgabe der Wellenlänge abrufen
 | 
			
		||||
            returncode = Wellenlaenge(color);
 | 
			
		||||
            if (returncode == 10){
 | 
			
		||||
                return 10;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Ungültige Eingabe
 | 
			
		||||
        else {
 | 
			
		||||
            printf("Bitte geben Sie die Nummer eins (1) oder zwei (2) ein. Nichts anderes!!!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#ifndef Rechner_Wellenlaenge2_H_ 
 | 
			
		||||
#define Rechner_Wellenlaenge2_H_ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   int Wellenlaengen_rechner_main();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										153
									
								
								src/Haenchen-vz/Haenchen_Drehmoment.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								src/Haenchen-vz/Haenchen_Drehmoment.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,153 @@
 | 
			
		||||
/* Haenchen_Drehmoment.c
 | 
			
		||||
Thema: Programm das einem das Rechnen mit Drehmomenten erleichtert.
 | 
			
		||||
Autoren: Glenn Robin Rahts & Jonas Michael Aufschläger
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version: 0.1
 | 
			
		||||
Datum: 13.12.2024
 | 
			
		||||
Änderungen:
 | 
			
		||||
0.1: 13.12.2024 Erste Version
 | 
			
		||||
0.2: 16.12.2024 Fehlersuche und Code anpassungen
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Einbinden von Headerdateien der Programmbibliothek.
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
// Mit main beginnt unser Programm.
 | 
			
		||||
 | 
			
		||||
int Haenchen_Drehmoment_main() {
 | 
			
		||||
// Variablen
 | 
			
		||||
  char input_start[5]; // Inputvariable für Programmstart
 | 
			
		||||
  char input_loop[5]; // Inputvariable für Berechnungsart
 | 
			
		||||
  char input_t[20]; // Inputvariable Drehmoment
 | 
			
		||||
  char input_l[20]; // Inputvariable Wirkungslaenge
 | 
			
		||||
  char input_f[20]; // Inputvariable Kraft
 | 
			
		||||
  int var_return = 0; // Variable zum beenden
 | 
			
		||||
  float value_t = 0; // Umgewandelter Wert Drehmoment
 | 
			
		||||
  float value_l = 0; // Umgewandelter Wert Wirkungslaenge
 | 
			
		||||
  float value_f = 0; // Umgewandelter Wert Kraft
 | 
			
		||||
  float output_t = 0; // Outputvariable Drehmoment
 | 
			
		||||
  float output_l = 0; // Outputvariable Wirkungslaenge
 | 
			
		||||
  float output_f = 0; // Outputvariable Kraft
 | 
			
		||||
  
 | 
			
		||||
  // Legende zur Funktionsweise des Unterprogramms wird ausgegeben
 | 
			
		||||
  printf("Herzlich Willkommen zum DREHMOMENTRECHNER!\n");
 | 
			
		||||
  printf("Dieses Unterprogramm laesst sich jederzeit mit der 'Q'-Taste beenden.\n");
 | 
			
		||||
  printf("Willst du ein Drehmoment berechnen?\n Ja oder Nein:\n");
 | 
			
		||||
  scanf("%s", &input_start[0]);
 | 
			
		||||
  while (getchar() != '\n'); // Pufferspeicher leeren
 | 
			
		||||
  
 | 
			
		||||
  if (strcmp(input_start, "Ja") == 0) { // Drehmoment berchnen in While Schlaufe
 | 
			
		||||
  
 | 
			
		||||
   while (1) {
 | 
			
		||||
	  printf("Wenn du das Drehmoment aus Wirkungslaenge und Kraft berechnen willst gib ein: M\n");
 | 
			
		||||
	  printf("Wenn du die Wirkungslaenge aus Drehmoment und Kraft berechnen willst gib ein: l\n");
 | 
			
		||||
	  printf("Wenn du die kraft aus Drehmoment und Wirkungslaenge berechnen willst gib ein: F\n");
 | 
			
		||||
	  scanf("%s",&input_loop[0]);
 | 
			
		||||
	  while (getchar() != '\n'); // Pufferspeicher leeren
 | 
			
		||||
	  
 | 
			
		||||
	  if (strcmp(input_loop, "M") == 0) { // Drehmoment
 | 
			
		||||
		  printf("Deine Wirkungslaenge: \n");
 | 
			
		||||
		  scanf("%s", &input_l);
 | 
			
		||||
		  if (input_l[0] == 'q' || input_l[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  printf("Deine Kraft: \n");
 | 
			
		||||
		  scanf("%s", &input_f);
 | 
			
		||||
		   if (input_f[0] == 'q' || input_f[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  value_l = atof(input_l);
 | 
			
		||||
          value_f = atof(input_f);
 | 
			
		||||
          output_t = value_l * value_f;
 | 
			
		||||
          printf("Dein Drehmoment ist: %f\n", output_t);
 | 
			
		||||
		  printf("Wenn du kein Drehmoment mehr Berechnen willst gib ein: Genug\n");
 | 
			
		||||
		  
 | 
			
		||||
	  }
 | 
			
		||||
	  
 | 
			
		||||
	  else if (strcmp(input_loop, "l") == 0) { // Wirkungslaenge
 | 
			
		||||
		  printf("Dein Drehmoment: \n");
 | 
			
		||||
		  scanf("%s", &input_t);
 | 
			
		||||
		   if (input_t[0] == 'q' || input_t[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  printf("Deine Kraft: \n");
 | 
			
		||||
		  scanf("%s", &input_f);
 | 
			
		||||
		   if (input_f[0] == 'q' || input_f[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  value_t = atof(input_t);
 | 
			
		||||
          value_f = atof(input_f);
 | 
			
		||||
          output_l = value_t / value_f;
 | 
			
		||||
          printf("Deine Wirkungslaenge ist: %f\n", output_l);
 | 
			
		||||
		  printf("Wenn du kein Drehmoment mehr Berechnen willst gib ein: Genug\n");
 | 
			
		||||
		  
 | 
			
		||||
	  }
 | 
			
		||||
	  
 | 
			
		||||
	  else if (strcmp(input_loop, "F") == 0) { // Kraft
 | 
			
		||||
		  printf("Dein Drehmoment: \n");
 | 
			
		||||
		  scanf("%s", &input_t);
 | 
			
		||||
		   if (input_t[0] == 'q' || input_t[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  printf("Deine Wirkungslaenge: \n");
 | 
			
		||||
		  scanf("%s", &input_l);
 | 
			
		||||
		   if (input_l[0] == 'q' || input_l[0] == 'Q') {
 | 
			
		||||
			  var_return = 10;
 | 
			
		||||
			  break;
 | 
			
		||||
		  }
 | 
			
		||||
		  value_t = atof(input_t);
 | 
			
		||||
          value_l = atof(input_l);
 | 
			
		||||
          output_f = value_t / value_l;
 | 
			
		||||
          printf("Deine Kraft ist: %f\n", output_f);
 | 
			
		||||
		  printf("Wenn du kein Drehmoment mehr Berechnen willst gib ein: Genug\n");
 | 
			
		||||
 | 
			
		||||
	  }
 | 
			
		||||
	  
 | 
			
		||||
      else if (input_loop[0] == 'q' || input_loop[0] == 'Q') { // Abbruch
 | 
			
		||||
		  var_return = 10;
 | 
			
		||||
		  break;
 | 
			
		||||
	  }
 | 
			
		||||
	  
 | 
			
		||||
	  else if (strcmp(input_loop, "Genug") == 0) { // Abbruch
 | 
			
		||||
		  var_return = 0;
 | 
			
		||||
		  break;
 | 
			
		||||
	  }
 | 
			
		||||
	  
 | 
			
		||||
	  else { // Falsche Eingabe
 | 
			
		||||
		  printf("Du huere sautubel du, aes hett gheisse: M,l,F / Genug!\n");
 | 
			
		||||
		  var_return = 20;
 | 
			
		||||
		  break;
 | 
			
		||||
	  }
 | 
			
		||||
   }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  else if (strcmp(input_start, "Nein") == 0) { //Beenden des Programms
 | 
			
		||||
	  var_return = 0;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  else if (input_start[0] == 'q' || input_start[0] == 'Q') { // Abbruch
 | 
			
		||||
	  var_return = 10;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  else { // Falsche Eingabe
 | 
			
		||||
	  printf("Du huere sautubel du, aes isch ae Ja/Nei frag!\n");
 | 
			
		||||
	  var_return = 20;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  // Präprozessoranweisung (Linux oder Windows?)
 | 
			
		||||
  #ifndef __linux__ // Hält die Konsole offen.
 | 
			
		||||
  system("pause");
 | 
			
		||||
  #endif
 | 
			
		||||
  
 | 
			
		||||
  // Rückgabewert, dass das Programm erfolgreich beendet wurde.
 | 
			
		||||
  return var_return;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/Haenchen-vz/Haenchen_Drehmoment.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/Haenchen-vz/Haenchen_Drehmoment.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#ifndef HAENCHEN_DREHMOMENT_H_ 
 | 
			
		||||
#define HAENCHEN_DREHMOMENT_H_ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   int Haenchen_Drehmoment_main();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										34
									
								
								src/Main-vz/kbhit_linux.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/Main-vz/kbhit_linux.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <termios.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
 
 | 
			
		||||
int kbhit(void)
 | 
			
		||||
{
 | 
			
		||||
  struct termios oldt, newt;
 | 
			
		||||
  int ch;
 | 
			
		||||
  int oldf;
 | 
			
		||||
 
 | 
			
		||||
  tcgetattr(STDIN_FILENO, &oldt);
 | 
			
		||||
  newt = oldt;
 | 
			
		||||
  newt.c_lflag &= ~(ICANON | ECHO);
 | 
			
		||||
  tcsetattr(STDIN_FILENO, TCSANOW, &newt);
 | 
			
		||||
  oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
 | 
			
		||||
  fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
 | 
			
		||||
 
 | 
			
		||||
  ch = getchar();
 | 
			
		||||
 
 | 
			
		||||
  tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
 | 
			
		||||
  fcntl(STDIN_FILENO, F_SETFL, oldf);
 | 
			
		||||
 
 | 
			
		||||
  if(ch != EOF)
 | 
			
		||||
  {
 | 
			
		||||
    ungetc(ch, stdin);
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										6
									
								
								src/Main-vz/kbhit_linux.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/Main-vz/kbhit_linux.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#ifndef KBHIT_LINUX_H_ 
 | 
			
		||||
#define KBHIT_LINUX_H_ 
 | 
			
		||||
 | 
			
		||||
int kbhit();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										109
									
								
								src/Main-vz/pipes2.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								src/Main-vz/pipes2.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,109 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
// #include <termios.h>
 | 
			
		||||
// #include <fcntl.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
#include "kbhit_linux.h"
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GRID_GROESSE_X 200
 | 
			
		||||
#define GRID_GROESSE_Y 60
 | 
			
		||||
#define SLEEP_TIME 40000
 | 
			
		||||
 | 
			
		||||
#define RED "\033[31m"
 | 
			
		||||
#define GREEN "\033[32m"
 | 
			
		||||
#define YELLOW "\033[33m"
 | 
			
		||||
#define BLUE "\033[34m"
 | 
			
		||||
#define MAGENTA "\033[35m"
 | 
			
		||||
#define CYAN "\033[36m"
 | 
			
		||||
#define WHITE "\033[37m"
 | 
			
		||||
 | 
			
		||||
const char *colors2[] = {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
 | 
			
		||||
 | 
			
		||||
int randome(int max){
 | 
			
		||||
    return rand() % max;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_at(int x, int y, char c[4], char color)
 | 
			
		||||
{
 | 
			
		||||
   printf("%s\033[%d;%dH%s", colors2[color], y, x, c);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char print_pipe(int *x, int *y, int x_max, int y_max, int length, char direction, char direction_old, char *color){
 | 
			
		||||
    if ((direction == 0 && direction_old == 1) || (direction == 1 && direction_old == 0)){
 | 
			
		||||
        return direction_old;
 | 
			
		||||
    } else if ((direction == 2 && direction_old == 3) || (direction == 3 && direction_old == 2)){
 | 
			
		||||
        return direction_old;
 | 
			
		||||
    }
 | 
			
		||||
    bool start = true;
 | 
			
		||||
    for(int i = 0; i < length; i++){
 | 
			
		||||
 | 
			
		||||
        if (start && direction != direction_old){
 | 
			
		||||
            switch (direction_old){
 | 
			
		||||
                case 0: *y -= 1; if (*y <= 0){ *y = y_max; *color = randome(7); } break; // up
 | 
			
		||||
                case 1: *y += 1; if (*y > y_max){ *y = 0; *color = randome(7); } break; // down
 | 
			
		||||
                case 2: *x -= 1; if (*x <= 0){ *x = x_max; *color = randome(7); } break; // left
 | 
			
		||||
                case 3: *x += 1; if (*x >= x_max){ *x = 0; *color = randome(7); } break; // rigth
 | 
			
		||||
            }
 | 
			
		||||
            if ((direction == 2 && direction_old == 0) || (direction == 1 && direction_old == 3)){
 | 
			
		||||
                print_at(*x, *y, "┓", *color);
 | 
			
		||||
            } else if ((direction == 0 && direction_old == 2) || (direction == 3 && direction_old == 1)) {
 | 
			
		||||
                print_at(*x, *y, "┗", *color);
 | 
			
		||||
            } else if ((direction == 3 && direction_old == 0) || (direction == 1 && direction_old == 2)) {
 | 
			
		||||
                print_at(*x, *y, "┏", *color);
 | 
			
		||||
            } else if ((direction == 0 && direction_old == 3) || (direction == 2 && direction_old == 1)) {
 | 
			
		||||
                print_at(*x, *y, "┛", *color);
 | 
			
		||||
            } // else { printf("\nd = %i | d_o = %i\n", direction, direction_old); }
 | 
			
		||||
            start = false;
 | 
			
		||||
        } else {
 | 
			
		||||
            switch (direction){
 | 
			
		||||
                case 0: *y -= 1; if (*y <= 0){ *y = y_max; *color = randome(7); } break; // up
 | 
			
		||||
                case 1: *y += 1; if (*y > y_max){ *y = 0; *color = randome(7); } break; // down
 | 
			
		||||
                case 2: *x -= 1; if (*x <= 0){ *x = x_max; *color = randome(7); } break; // left
 | 
			
		||||
                case 3: *x += 1; if (*x >= x_max){ *x = 0; *color = randome(7); } break; // rigth
 | 
			
		||||
            }
 | 
			
		||||
            if (direction <= 1) {
 | 
			
		||||
                print_at(*x, *y, "┃", *color);
 | 
			
		||||
            } else {
 | 
			
		||||
                print_at(*x, *y, "━", *color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        fflush(stdout);
 | 
			
		||||
        usleep(SLEEP_TIME);
 | 
			
		||||
    }
 | 
			
		||||
    return direction;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pipes_2(int width, int height){
 | 
			
		||||
    int x_max = width;
 | 
			
		||||
    int y_max =height;
 | 
			
		||||
    int x = width / 2;
 | 
			
		||||
    int y = height / 2;
 | 
			
		||||
    char direction_old = 0;
 | 
			
		||||
    char color = 6;
 | 
			
		||||
    int start_time = 0;
 | 
			
		||||
    srand(time(0));
 | 
			
		||||
 | 
			
		||||
    while(!kbhit()){
 | 
			
		||||
        if (start_time + 20 <= time(0)){
 | 
			
		||||
            printf("\e[1;1H\e[2J"); // clear terminal
 | 
			
		||||
            start_time = time(0);
 | 
			
		||||
        }
 | 
			
		||||
        direction_old = print_pipe(&x, &y, x_max, y_max, randome(height / 3) + 1, randome(4), direction_old, &color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // ist dazu da um "\n" aus dem buffer zu entfernen!
 | 
			
		||||
    getchar();
 | 
			
		||||
 | 
			
		||||
    printf("\033[00m"); // Farbe zurücksetzen
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								src/Main-vz/pipes2.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/Main-vz/pipes2.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
#ifndef pipes2_H_
 | 
			
		||||
#define pipes2_H_
 | 
			
		||||
 | 
			
		||||
// #ifndef _FILE_NAME_H_ 
 | 
			
		||||
// #define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
// extern int pipes(int width, int height);
 | 
			
		||||
int pipes_2(int width, int height);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										158
									
								
								src/Main-vz/pipes2_game.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										158
									
								
								src/Main-vz/pipes2_game.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,158 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
    #include <sys/ioctl.h>
 | 
			
		||||
    #include <unistd.h>
 | 
			
		||||
    #include <termio.h>
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// #include <termios.h>
 | 
			
		||||
// #include <fcntl.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
#include "kbhit_linux.h"
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GRID_GROESSE_X 200
 | 
			
		||||
#define GRID_GROESSE_Y 60
 | 
			
		||||
#define SLEEP_TIME 0
 | 
			
		||||
 | 
			
		||||
#define RED "\033[31m"
 | 
			
		||||
#define GREEN "\033[32m"
 | 
			
		||||
#define YELLOW "\033[33m"
 | 
			
		||||
#define BLUE "\033[34m"
 | 
			
		||||
#define MAGENTA "\033[35m"
 | 
			
		||||
#define CYAN "\033[36m"
 | 
			
		||||
#define WHITE "\033[37m"
 | 
			
		||||
 | 
			
		||||
const char *colors3[] = {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
int getch_pipese(){ 
 | 
			
		||||
    int ch;
 | 
			
		||||
    struct termios oldattr, newattr;
 | 
			
		||||
 | 
			
		||||
    tcgetattr(STDIN_FILENO, &oldattr);
 | 
			
		||||
    newattr = oldattr;
 | 
			
		||||
    newattr.c_lflag &= ~ICANON;
 | 
			
		||||
    newattr.c_lflag &= ~ECHO;
 | 
			
		||||
    newattr.c_cc[VMIN] = 1;
 | 
			
		||||
    newattr.c_cc[VTIME] = 0;
 | 
			
		||||
    tcsetattr(STDIN_FILENO, TCSANOW, &newattr);
 | 
			
		||||
    ch = getchar();
 | 
			
		||||
    tcsetattr(STDIN_FILENO, TCSANOW, &oldattr);
 | 
			
		||||
 | 
			
		||||
    return ch; 
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int randomee(int max){
 | 
			
		||||
    return rand() % max;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_ate(int x, int y, char c[4], char color)
 | 
			
		||||
{
 | 
			
		||||
   printf("%s\033[%d;%dH%s", colors3[color], y, x, c);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char print_pipee(int *x, int *y, int x_max, int y_max, int length, char direction, char direction_old, char *color){
 | 
			
		||||
    if ((direction == 0 && direction_old == 1) || (direction == 1 && direction_old == 0)){
 | 
			
		||||
        return direction_old;
 | 
			
		||||
    } else if ((direction == 2 && direction_old == 3) || (direction == 3 && direction_old == 2)){
 | 
			
		||||
        return direction_old;
 | 
			
		||||
    }
 | 
			
		||||
    bool start = true;
 | 
			
		||||
    for(int i = 0; i < length; i++){
 | 
			
		||||
 | 
			
		||||
        if (start && direction != direction_old){
 | 
			
		||||
 | 
			
		||||
            switch (direction_old){
 | 
			
		||||
                case 0: *y -= 1; if (*y <= 0){ *y = y_max; *color = randomee(7); } break; // up
 | 
			
		||||
                case 1: *y += 1; if (*y > y_max){ *y = 0; *color = randomee(7); } break; // down
 | 
			
		||||
                case 2: *x -= 1; if (*x <= 0){ *x = x_max; *color = randomee(7); } break; // left
 | 
			
		||||
                case 3: *x += 1; if (*x >= x_max){ *x = 0; *color = randomee(7); } break; // rigth
 | 
			
		||||
            }
 | 
			
		||||
            if ((direction == 2 && direction_old == 0) || (direction == 1 && direction_old == 3)){
 | 
			
		||||
                print_ate(*x, *y, "┓", *color);
 | 
			
		||||
            } else if ((direction == 0 && direction_old == 2) || (direction == 3 && direction_old == 1)) {
 | 
			
		||||
                print_ate(*x, *y, "┗", *color);
 | 
			
		||||
            } else if ((direction == 3 && direction_old == 0) || (direction == 1 && direction_old == 2)) {
 | 
			
		||||
                print_ate(*x, *y, "┏", *color);
 | 
			
		||||
            } else if ((direction == 0 && direction_old == 3) || (direction == 2 && direction_old == 1)) {
 | 
			
		||||
                print_ate(*x, *y, "┛", *color);
 | 
			
		||||
            } // else { printf("\nd = %i | d_o = %i\n", direction, direction_old); }
 | 
			
		||||
            start = false;
 | 
			
		||||
        } else {
 | 
			
		||||
            switch (direction){
 | 
			
		||||
                case 0: *y -= 1; if (*y <= 0){ *y = y_max; *color = randomee(7); } break; // up
 | 
			
		||||
                case 1: *y += 1; if (*y > y_max){ *y = 0; *color = randomee(7); } break; // down
 | 
			
		||||
                case 2: *x -= 1; if (*x <= 0){ *x = x_max; *color = randomee(7); } break; // left
 | 
			
		||||
                case 3: *x += 1; if (*x >= x_max){ *x = 0; *color = randomee(7); } break; // rigth
 | 
			
		||||
            }
 | 
			
		||||
            if (direction <= 1) {
 | 
			
		||||
                print_ate(*x, *y, "┃", *color);
 | 
			
		||||
            } else {
 | 
			
		||||
                print_ate(*x, *y, "━", *color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        fflush(stdout);
 | 
			
		||||
        usleep(SLEEP_TIME);
 | 
			
		||||
    }
 | 
			
		||||
    return direction;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pipes_2_game(int width, int height){
 | 
			
		||||
    int x_max = width;
 | 
			
		||||
    int y_max =height;
 | 
			
		||||
    int x = width / 2;
 | 
			
		||||
    int y = height / 2;
 | 
			
		||||
    char direction_old = 0;
 | 
			
		||||
    char color = 6;
 | 
			
		||||
    int start_time = 0;
 | 
			
		||||
    srand(time(0));
 | 
			
		||||
 | 
			
		||||
    while(!kbhit()){
 | 
			
		||||
        int richtung = 0;
 | 
			
		||||
        int length = 4;
 | 
			
		||||
        if (start_time + 20 <= time(0)){
 | 
			
		||||
            printf("\e[1;1H\e[2J"); // clear terminal
 | 
			
		||||
            start_time = time(0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
            #ifdef __linux__
 | 
			
		||||
                char key_input = (char)getch_pipese();
 | 
			
		||||
            #elif _WIN32
 | 
			
		||||
                char key_input = (char)getch();
 | 
			
		||||
            #endif
 | 
			
		||||
            switch (key_input) {
 | 
			
		||||
                case 'h': richtung = 2; break;
 | 
			
		||||
                case 'a': richtung = 2; break;
 | 
			
		||||
                case 'l': richtung = 3; break;
 | 
			
		||||
                case 'd': richtung = 3; break;
 | 
			
		||||
                case 'j': richtung = 1; break;
 | 
			
		||||
                case 's': richtung = 1; break;
 | 
			
		||||
                case 'k': richtung = 0; break;
 | 
			
		||||
                case 'w': richtung = 0; break;
 | 
			
		||||
                case 'q': return 0;
 | 
			
		||||
                default: continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        direction_old = print_pipee(&x, &y, x_max, y_max, length, richtung, direction_old, &color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // ist dazu da um "\n" aus dem buffer zu entfernen!
 | 
			
		||||
    getchar();
 | 
			
		||||
 | 
			
		||||
    printf("\033[00m"); // Farbe zurücksetzen
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								src/Main-vz/pipes2_game.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/Main-vz/pipes2_game.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
#ifndef pipes2_game_H_
 | 
			
		||||
#define pipes2_game_H_
 | 
			
		||||
 | 
			
		||||
// #ifndef _FILE_NAME_H_ 
 | 
			
		||||
// #define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
// extern int pipes(int width, int height);
 | 
			
		||||
int pipes_2_game(int width, int height);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										384
									
								
								src/Main-vz/pipes_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										384
									
								
								src/Main-vz/pipes_test.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,384 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
    #include <sys/ioctl.h>
 | 
			
		||||
    #include <unistd.h>
 | 
			
		||||
    #include <termio.h>
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define DEBUGGER_PIPES_TO_NUMBERS 0
 | 
			
		||||
#define DEBUGGER_RANDOM 0
 | 
			
		||||
#define AUTOMATISCH 0
 | 
			
		||||
 | 
			
		||||
#define INFILL_PLAIN_PAPER 0
 | 
			
		||||
#define INFILL_X_PIPE 1
 | 
			
		||||
#define INFILL_Y_PIPE 2
 | 
			
		||||
#define FILLER " "                      // ░
 | 
			
		||||
 | 
			
		||||
//#define GRID_GROESSE_X 120              // x:y -> 2:1 for a square looking grid
 | 
			
		||||
//#define GRID_GROESSE_Y 60
 | 
			
		||||
#define MIN_LAENGE_PIPE 6
 | 
			
		||||
#define MAX_LAENGE_PIPE 6
 | 
			
		||||
#define SLEEP_TIMER 0              // in nano seconds
 | 
			
		||||
// #define SLEEP_TIMER 5000              // in nano seconds
 | 
			
		||||
#define COLOR_CHANGING_PROBABILITY 5   // format: "(1 : your_number)", for every direction change
 | 
			
		||||
 | 
			
		||||
#define RESET_COLOR "\033[0m"
 | 
			
		||||
#define RED "\033[31m"
 | 
			
		||||
#define GREEN "\033[32m"
 | 
			
		||||
#define YELLOW "\033[33m"
 | 
			
		||||
#define BLUE "\033[34m"
 | 
			
		||||
#define MAGENTA "\033[35m"
 | 
			
		||||
#define CYAN "\033[36m"
 | 
			
		||||
#define WHITE "\033[37m"
 | 
			
		||||
 | 
			
		||||
const char* color;
 | 
			
		||||
const char *colors[] = {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
 | 
			
		||||
 | 
			
		||||
void random_color() {
 | 
			
		||||
    color = colors[rand() % (sizeof(colors) / sizeof(colors[0]))];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
int getch_pipes(){ 
 | 
			
		||||
    int ch;
 | 
			
		||||
    struct termios oldattr, newattr;
 | 
			
		||||
 | 
			
		||||
    tcgetattr(STDIN_FILENO, &oldattr);
 | 
			
		||||
    newattr = oldattr;
 | 
			
		||||
    newattr.c_lflag &= ~ICANON;
 | 
			
		||||
    newattr.c_lflag &= ~ECHO;
 | 
			
		||||
    newattr.c_cc[VMIN] = 1;
 | 
			
		||||
    newattr.c_cc[VTIME] = 0;
 | 
			
		||||
    tcsetattr(STDIN_FILENO, TCSANOW, &newattr);
 | 
			
		||||
    ch = getchar();
 | 
			
		||||
    tcsetattr(STDIN_FILENO, TCSANOW, &oldattr);
 | 
			
		||||
 | 
			
		||||
    return ch; 
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int print_grid(int x, int y, char **grid, int how_many_targets, int *lul) {
 | 
			
		||||
    int target_count = 0;
 | 
			
		||||
    for (int i = 0; i < y; i++) {
 | 
			
		||||
        printf("\n");
 | 
			
		||||
        for (int j = 0; j < x; j++) {
 | 
			
		||||
            if(grid[i][j] == 3){
 | 
			
		||||
                target_count += 1;
 | 
			
		||||
            }if (!DEBUGGER_PIPES_TO_NUMBERS){
 | 
			
		||||
                if(grid[i][j] == 0){
 | 
			
		||||
                    printf(FILLER);
 | 
			
		||||
                } else if(grid[i][j] == 3){
 | 
			
		||||
                    printf("%s█","\033[31m" );
 | 
			
		||||
                } else if(grid[i][j] != 0 && grid[i][j] != 1 && grid[i][j] != 2 && grid[i][j] != 3){
 | 
			
		||||
                    return 1;
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s╋", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┓", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┗", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┏", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┛", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┣", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┫", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┳", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┻", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] == 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] != 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] != 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 1 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 1 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 1 && grid[i + 1][j] == 1 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 2 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 2 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 2 && grid[i][j + 1] == 2 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i][j] == 3){
 | 
			
		||||
                    printf("✨");
 | 
			
		||||
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 0  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┻", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┳", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j + 1] == 0 && grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┗", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
                } else{printf("x");}
 | 
			
		||||
                    printf(RESET_COLOR); // Setzt die Farbe zurück
 | 
			
		||||
            }else{
 | 
			
		||||
                printf("%i", grid[i][j]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (target_count <= 2*how_many_targets - 1*how_many_targets) {
 | 
			
		||||
        printf("\e[1;1H\e[2J");
 | 
			
		||||
        printf("\n");
 | 
			
		||||
        printf(" █     █   █████   █     █    █      █   █████   ██   █\n");
 | 
			
		||||
        printf(" ██   ██  █     █  █     █    █      █  █     █  ███  █\n");
 | 
			
		||||
        printf("  █████   █     █  █     █    █      █  █     █  █ ██ █\n");
 | 
			
		||||
        printf("    █     █     █  █     █     █ ██ █   █     █  █  ███\n");
 | 
			
		||||
        printf("    █      █████    █████       █  █     █████   █   ██\n");
 | 
			
		||||
        printf("\n");
 | 
			
		||||
        printf("Targets overritten: %i\n", 2*how_many_targets-target_count);
 | 
			
		||||
        *lul += 1;
 | 
			
		||||
        system("xdg-open https://bit.ly/3BlS71b");
 | 
			
		||||
        printf("'q' for start menue");
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int generate_pipe_x(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets, int *return_code, int *lul) {
 | 
			
		||||
    if (laenge < 0){
 | 
			
		||||
        for (int i = *x_start; i > *x_start + laenge; i--) {
 | 
			
		||||
            if (*return_code == 1) {
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            if (i <= -laenge/2 -1) {
 | 
			
		||||
                *x_start = GRID_GROESSE_X + laenge/2;
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            grid[*y_start][i] = INFILL_X_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        for (int i = *x_start; i < *x_start + laenge; i++) {
 | 
			
		||||
            if (*return_code == 1) {
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            if (i >= GRID_GROESSE_X - laenge/2+1) {
 | 
			
		||||
                *x_start = laenge/2;
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            grid[*y_start][i] = INFILL_X_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    *x_start += laenge;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int generate_pipe_y(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge, int how_many_targets, int *return_code, int *lul) {
 | 
			
		||||
    if (laenge < 0){
 | 
			
		||||
        for (int i = *y_start; i > *y_start + laenge/2; i--) {
 | 
			
		||||
            if (*return_code == 1) {
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            if (i <= -laenge/2) {
 | 
			
		||||
                *y_start = GRID_GROESSE_Y + laenge/2;
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            grid[i][*x_start] = INFILL_Y_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul);
 | 
			
		||||
        }
 | 
			
		||||
    } else{
 | 
			
		||||
        for (int i = *y_start; i < *y_start + laenge/2; i++) {
 | 
			
		||||
            if (*return_code == 1) {
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            if (i >= (GRID_GROESSE_Y / 2)*2 - 1) {
 | 
			
		||||
                *y_start = laenge/2;
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            grid[i][*x_start] = INFILL_Y_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            *return_code = print_grid(GRID_GROESSE_X, GRID_GROESSE_Y, grid, how_many_targets, lul);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    *y_start += laenge/2;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void generate_target(int GRID_GROESSE_X, int GRID_GROESSE_Y, char **grid, int *x_start, int *y_start, int laenge) {
 | 
			
		||||
    int abstand_vom_rand_x = 6;
 | 
			
		||||
    int abstand_vom_rand_y = 3;
 | 
			
		||||
    int target_x = 0;
 | 
			
		||||
    int target_y = 0;
 | 
			
		||||
    while (target_x <= abstand_vom_rand_x || target_x >= GRID_GROESSE_X - abstand_vom_rand_x || target_y <= abstand_vom_rand_y || target_y >= GRID_GROESSE_Y - abstand_vom_rand_y) {  
 | 
			
		||||
        target_x = ((rand() % GRID_GROESSE_X));
 | 
			
		||||
        target_y = ((rand() % GRID_GROESSE_Y));
 | 
			
		||||
    }
 | 
			
		||||
    for (int j = target_y; j < target_y + 2; j++) {
 | 
			
		||||
        for (int i = target_x; i < target_x + 1; i++) {
 | 
			
		||||
                grid[j][i] = 3;
 | 
			
		||||
            }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
int pipes(int GRID_GROESSE_X, int GRID_GROESSE_Y) {
 | 
			
		||||
//int main() {
 | 
			
		||||
//    system("chcp 65001 >null"); 
 | 
			
		||||
//    int GRID_GROESSE_X = 100;              // x:y -> 2:1 for a square looking grid
 | 
			
		||||
//    int GRID_GROESSE_Y = 60;
 | 
			
		||||
 | 
			
		||||
    int x_start = GRID_GROESSE_X / 2;
 | 
			
		||||
    int y_start = GRID_GROESSE_Y / 2;
 | 
			
		||||
    int laenge = 20;
 | 
			
		||||
    int max_l = MAX_LAENGE_PIPE + 1 - MIN_LAENGE_PIPE;
 | 
			
		||||
    int min_l = MIN_LAENGE_PIPE - 1;
 | 
			
		||||
    int color_c_p = COLOR_CHANGING_PROBABILITY + 1;
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    int lul = 0;
 | 
			
		||||
    srand(time(NULL));
 | 
			
		||||
 | 
			
		||||
    random_color();
 | 
			
		||||
 | 
			
		||||
    char **grid = malloc(GRID_GROESSE_Y * sizeof(char *));
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
        grid[i] = malloc(GRID_GROESSE_X * sizeof(char));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
        for (int j = 0; j < GRID_GROESSE_X; j++) {
 | 
			
		||||
            grid[i][j] = INFILL_PLAIN_PAPER;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // int richtungswechsler = 1;
 | 
			
		||||
    int how_many_targets = 3;
 | 
			
		||||
    for (int i = 1; i <= how_many_targets; i++) {
 | 
			
		||||
        generate_target(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
    }
 | 
			
		||||
    return_code = generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, 1, how_many_targets, &return_code, &lul);
 | 
			
		||||
 | 
			
		||||
    if (!DEBUGGER_RANDOM) {
 | 
			
		||||
 | 
			
		||||
        while (!AUTOMATISCH) {
 | 
			
		||||
            if ((rand() %color_c_p) <= 1) {
 | 
			
		||||
                random_color();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            laenge = ((rand() %max_l)+min_l);
 | 
			
		||||
        
 | 
			
		||||
            #ifdef __linux__
 | 
			
		||||
                char key_input = (char)getch_pipes();
 | 
			
		||||
            #elif _WIN32
 | 
			
		||||
                char key_input = (char)getch();
 | 
			
		||||
            #endif
 | 
			
		||||
            switch (key_input) {
 | 
			
		||||
                case 'h': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'a': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'l': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'd': generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'j': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 's': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'k': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'w': generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets, &return_code, &lul); break;
 | 
			
		||||
                case 'q': return 0;
 | 
			
		||||
                default: continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//        while (AUTOMATISCH) {
 | 
			
		||||
//            if ((rand() %color_c_p) <= 1) {
 | 
			
		||||
//                random_color();
 | 
			
		||||
//            }
 | 
			
		||||
//            if ((rand() %2)-1) {
 | 
			
		||||
//                laenge = ((rand() %max_l)+min_l);
 | 
			
		||||
//            } else {
 | 
			
		||||
//                laenge = ((rand() %max_l)+min_l)*-1;
 | 
			
		||||
//            }
 | 
			
		||||
//
 | 
			
		||||
//            if (richtungswechsler == 1) {
 | 
			
		||||
//                generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
//                richtungswechsler *= -1;
 | 
			
		||||
//            } else {
 | 
			
		||||
//                generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
//                richtungswechsler *= -1;
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    if (DEBUGGER_RANDOM) {
 | 
			
		||||
//        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
//        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
//        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
//        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1, how_many_targets);
 | 
			
		||||
//        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05, how_many_targets);
 | 
			
		||||
//        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1, how_many_targets);
 | 
			
		||||
//        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1, how_many_targets);
 | 
			
		||||
//        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9, how_many_targets);
 | 
			
		||||
//        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge, how_many_targets);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
        free(grid[i]);
 | 
			
		||||
        }
 | 
			
		||||
        free(grid);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								src/Main-vz/pipes_test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Main-vz/pipes_test.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
#ifndef pipes_test_H_
 | 
			
		||||
#define pipes_test_H_
 | 
			
		||||
 | 
			
		||||
// #ifndef _FILE_NAME_H_ 
 | 
			
		||||
// #define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
// extern int pipes(int width, int height);
 | 
			
		||||
// int pipes_2(int width, int height);
 | 
			
		||||
int pipes(int GRIG_GROESSE_X, int GRID_GROESSE_Y);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										439
									
								
								src/Ramen-vz/Ramen_Physik.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										439
									
								
								src/Ramen-vz/Ramen_Physik.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,439 @@
 | 
			
		||||
/* Ramen_Physik.c
 | 
			
		||||
Hier werden Physikaufgaben gelöst mit einem Spiel als Pause
 | 
			
		||||
 | 
			
		||||
Autor: Jana Nieblas, Debora Semmler
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 11.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 11.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Einbindung Bibliotheken
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Einbindung Dateien
 | 
			
		||||
#include "Tic_Tac_Toe.h"
 | 
			
		||||
 | 
			
		||||
//Definitionen
 | 
			
		||||
#define max_anzahl_fehler 3
 | 
			
		||||
 | 
			
		||||
// Abfrage Antworten
 | 
			
		||||
int antwort (int loesung, int *falsche_antwort){
 | 
			
		||||
 | 
			
		||||
    while (1)
 | 
			
		||||
    {
 | 
			
		||||
        int eingabe;
 | 
			
		||||
        scanf("%d", &eingabe);
 | 
			
		||||
 | 
			
		||||
        if (eingabe == loesung)
 | 
			
		||||
        {
 | 
			
		||||
            printf("Richtige Antwort \n");
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        else {
 | 
			
		||||
            printf("Falsche antwort \n");
 | 
			
		||||
            *falsche_antwort += 1;
 | 
			
		||||
           if (*falsche_antwort >= max_anzahl_fehler) {
 | 
			
		||||
                printf("Zu viele ungültige Eingaben. Programm beendet.\n");
 | 
			
		||||
 | 
			
		||||
                fflush(stdout);
 | 
			
		||||
                //Sleep
 | 
			
		||||
                #ifdef __linux__
 | 
			
		||||
                    sleep(2);
 | 
			
		||||
                #elif _WIN32
 | 
			
		||||
                    // Sleep ist in Milisekunden
 | 
			
		||||
                    Sleep(2 * 1000);
 | 
			
		||||
                #endif
 | 
			
		||||
 | 
			
		||||
                return 20;
 | 
			
		||||
            }
 | 
			
		||||
        }    
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Zufällige Ausgabe der Fragen
 | 
			
		||||
int zufaellig(int maximum){
 | 
			
		||||
    int n = rand() % maximum;
 | 
			
		||||
    return n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//einfache Fragen
 | 
			
		||||
int einfache_fragen(int *falsche_antwort){
 | 
			
		||||
 | 
			
		||||
    //Variabeln
 | 
			
		||||
    const int anzahl_fragen = 8;
 | 
			
		||||
    int fragen[3] = {-1, -1,-1};
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    int x = 0;
 | 
			
		||||
 | 
			
		||||
    //Lösungseingabe
 | 
			
		||||
    printf("Gib '1' ein falls die Aussage wahr ist und '2' falls die Aussage falsch ist. \n \n");
 | 
			
		||||
 | 
			
		||||
    //abfragen der verwendeten Fragen
 | 
			
		||||
    for (int i = 0; i < 3; i++)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        while (1)      
 | 
			
		||||
        {
 | 
			
		||||
            x = zufaellig(anzahl_fragen);
 | 
			
		||||
 | 
			
		||||
            if (x != fragen[0] && x != fragen[1] && x != fragen[2])
 | 
			
		||||
            {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        fragen[i]=x;
 | 
			
		||||
 | 
			
		||||
        //Fragen
 | 
			
		||||
        switch (x)
 | 
			
		||||
        {
 | 
			
		||||
        case 0 :
 | 
			
		||||
            printf("Der relative Fehler ist eine Grösse ohne Masseinheit. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 1 :
 | 
			
		||||
            printf("Es gilt 10^-12 nm = 1 km  \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 2 :
 | 
			
		||||
            printf("Die Gewichtskraft eines Objektes steigt linear mit dessen Masse. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 3 :
 | 
			
		||||
            printf("Ein Druck kann sowohl in Flüssigkeiten als auch in Gasen herrschen. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 4 :
 | 
			
		||||
            printf("Der Luftdruck auf Meereshöhe beträgt ca. 10 bar.  \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 5 :
 | 
			
		||||
            printf("Die barometrische Höhenformel gilt unter der Annahme, dass die Luft in der Atmosphäre überall die gleiche Temperatur hat. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 6 :
 | 
			
		||||
            printf("Es gilt ∆W = mg ∆h, wenn man Reibung und Luftwiderstand vernachlässigt. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 7 :
 | 
			
		||||
            printf("Wird eine Kugel von einer an der Wand befestigten Feder horizontal weggeschleudert wird, dann wird die elastische Energie in kinetische Energie umgewandelt.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (return_code == 20)
 | 
			
		||||
        {
 | 
			
		||||
            return 20;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
    return 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//mittlere Fragen
 | 
			
		||||
int mittlere_fragen(int *falsche_antwort){
 | 
			
		||||
 | 
			
		||||
    //Variabeln
 | 
			
		||||
    const int anzahl_fragen = 8;
 | 
			
		||||
    int fragen[3] = {-1, -1,-1};
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    int x = 0;
 | 
			
		||||
 | 
			
		||||
    //Lösungseingabe
 | 
			
		||||
    printf("Gib '1' ein falls die Aussage wahr ist und '2' falls die Aussage falsch ist. \n \n");
 | 
			
		||||
 | 
			
		||||
    //abfragen verwendeter Fragen
 | 
			
		||||
    for (int i = 0; i < 3; i++)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        while (1)      
 | 
			
		||||
        {
 | 
			
		||||
            x = zufaellig(anzahl_fragen);
 | 
			
		||||
 | 
			
		||||
            if (x != fragen[0] && x != fragen[1] && x != fragen[2])
 | 
			
		||||
            {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        fragen[i]=x;
 | 
			
		||||
 | 
			
		||||
        //Fragen
 | 
			
		||||
        switch (x)
 | 
			
		||||
        {
 | 
			
		||||
        case 0 :
 | 
			
		||||
            printf("In der Physik sind weltweit ausschliesslich SI-Einheiten in Gebrauch. \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 1 :
 | 
			
		||||
            printf("Das Prinzip actio et reactio ist eine Folge des Impuls-Erhaltungssatzes. \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 2 :
 | 
			
		||||
            printf("Befindet sich ein Körper im Stillstand, dann wirkt überhaupt keine Kraft auf ihn. \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 3 :
 | 
			
		||||
            printf("Verdoppelt man den Steigungswinkel einer Rampe, dann verdoppelt man auch ihre Steigung.  \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 4 :
 | 
			
		||||
            printf("Die Ruhepunkt-Methode basiert auf dem Newton-Aktionsprinzip.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 5 :
 | 
			
		||||
            printf("Mit Hilfe der Ruhepunkt-Methode erkennt man, ob die berechneten Kräfte eine Belastung auf Zug oder Druck bedeuten.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 6 :
 | 
			
		||||
            printf("Für jede Bewegung ist die geleistete Arbeit gleich der Fläche im s-F-Diagramm zwischen dem Graphen von F(s) und der s-Achse \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 7 :
 | 
			
		||||
            printf("Die Leistung quantifiziert den Energiestrom, d.h. die übertragene Energie pro Zeiteinheit auf ein Objekt.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (return_code == 20)
 | 
			
		||||
        {
 | 
			
		||||
            return 20;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
    return 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//schwere Fragen
 | 
			
		||||
int schwere_fragen(int *falsche_antwort){
 | 
			
		||||
 | 
			
		||||
    //Variabeln
 | 
			
		||||
    const int anzahl_fragen = 8;
 | 
			
		||||
    int fragen[3] = {-1, -1,-1};
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    int x = 0;
 | 
			
		||||
 | 
			
		||||
    //Lösungseingabe
 | 
			
		||||
    printf("Gib '1' ein falls die Aussage wahr ist und '2' falls die Aussage falsch ist. \n \n");
 | 
			
		||||
 | 
			
		||||
    //abfragen verwendeter Fragen
 | 
			
		||||
    for (int i = 0; i < 3; i++)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        while (1)      
 | 
			
		||||
        {
 | 
			
		||||
            x = zufaellig(anzahl_fragen);
 | 
			
		||||
 | 
			
		||||
            if (x != fragen[0] && x != fragen[1] && x != fragen[2])
 | 
			
		||||
            {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        fragen[i]=x;
 | 
			
		||||
 | 
			
		||||
        //Fragen
 | 
			
		||||
        switch (x)
 | 
			
		||||
        {
 | 
			
		||||
        case 0 :
 | 
			
		||||
            printf("Die 7 SI-Basis-Einheiten orientieren sich an den Grössenordnungen der Menschen.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 1 :
 | 
			
		||||
            printf("Die Ursache des Impuls-Erhaltungssatzes ist die Zeitunabhängigkeit der physikalischen Gesetze.  \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 2 :
 | 
			
		||||
            printf("Der Begriff Kraft quantifiziert den Impulsstrom, d.h. den Impulsübertrag pro Zeiteinheit auf ein Objekt.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 3 :
 | 
			
		||||
            printf("Wirkt auf ein fahrendes Auto nur der turbulente Strömungswiderstand, dann wird es gleichförmig abgebremst. \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 4 :
 | 
			
		||||
            printf("Die Leistung eines Blitzschlages kann die Leistung eines Grosskraftwerkes weit übertreffen.  \n");
 | 
			
		||||
            return_code = antwort(1, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 5 :
 | 
			
		||||
            printf("Wird ein Körper von der Geschwindigkeit v0 < 0 mit konstanter Leistung P auf eine Geschwindigkeit vE < v0 beschleunigt, dann gilt P < 0. \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 6 :
 | 
			
		||||
            printf("Ist die Beschleunigungsfunktion eines Objektes strikt negativ, d.h. gilt a(t) < 0 zu jeder Zeit t ≥ t0, dann bewegt sich das Objekt zu jeder Zeit t ≥ t0 in Rückwärtsrichtung (negative Bewegungsrichtung). \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case 7 :
 | 
			
		||||
            printf("Es seien ∆t = tE - t0, ∆s = sE - s0 und ∆v = vE - v0. Dann gilt für jede Bewegung v(t) = ∆s/∆t und a(t) = ∆v/∆t. \n");
 | 
			
		||||
            return_code = antwort(2, falsche_antwort);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (return_code == 20)
 | 
			
		||||
        {
 | 
			
		||||
            return 20;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
    return 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Hauptunktionen                                                            
 | 
			
		||||
int Ramen_Physik(){
 | 
			
		||||
 | 
			
		||||
    // Umlaute
 | 
			
		||||
    system("chcp 65001 >null");
 | 
			
		||||
 | 
			
		||||
    // Zufallsgenerator initialisieren
 | 
			
		||||
    srand(time(NULL));
 | 
			
		||||
 | 
			
		||||
    //Variabeln
 | 
			
		||||
    char eingabe = '0';
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    int falsche_antwort = 0;
 | 
			
		||||
 | 
			
		||||
    while (1){
 | 
			
		||||
        //löschen der Konsole
 | 
			
		||||
        printf("\e[1;1H\e[2J");
 | 
			
		||||
 | 
			
		||||
        //Auswahl der Schwierigkeitsstufe
 | 
			
		||||
        printf("1 \t einfache Fragen \n");
 | 
			
		||||
        printf("2 \t mittlere Fragen \n");
 | 
			
		||||
        printf("3 \t schwere Fragen \n");
 | 
			
		||||
        printf("q \t zurück zum Hauptmenu \n");
 | 
			
		||||
 | 
			
		||||
        scanf("%c", &eingabe);
 | 
			
		||||
 | 
			
		||||
        //Abfrage der Eingabe
 | 
			
		||||
        switch (eingabe){
 | 
			
		||||
            case '1':{
 | 
			
		||||
                printf("\neinfache Fragen\n");
 | 
			
		||||
                return_code = einfache_fragen(&falsche_antwort);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case '2':{
 | 
			
		||||
                printf("\nmittlere Fragen\n");
 | 
			
		||||
                return_code = mittlere_fragen(&falsche_antwort);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case '3':{
 | 
			
		||||
                printf("\nschwere Fragen\n");
 | 
			
		||||
                return_code = schwere_fragen(&falsche_antwort);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case '4':{
 | 
			
		||||
                Tic_Tac_Toe();
 | 
			
		||||
 | 
			
		||||
                fflush(stdout);
 | 
			
		||||
                //Sleep
 | 
			
		||||
                #ifdef __linux__
 | 
			
		||||
                    sleep(2);
 | 
			
		||||
                #elif _WIN32
 | 
			
		||||
                // Sleep ist in Milisekunden
 | 
			
		||||
                    Sleep(2 * 1000);
 | 
			
		||||
                #endif
 | 
			
		||||
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case 'q':{
 | 
			
		||||
                printf("\nProgramm beendet \n");
 | 
			
		||||
 | 
			
		||||
                fflush(stdout);
 | 
			
		||||
                //Sleep
 | 
			
		||||
                #ifdef __linux__
 | 
			
		||||
                    // sleep(2);
 | 
			
		||||
                #elif _WIN32
 | 
			
		||||
                // Sleep ist in Milisekunden
 | 
			
		||||
                    Sleep(2 * 1000);
 | 
			
		||||
                #endif
 | 
			
		||||
 | 
			
		||||
                return 10;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case '\n':{
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            default: {
 | 
			
		||||
                printf("Zu viele ungültige Eingaben. Programm beendet.\n");
 | 
			
		||||
 | 
			
		||||
                fflush(stdout);
 | 
			
		||||
                //Sleep
 | 
			
		||||
                #ifdef __linux__
 | 
			
		||||
                    sleep(2);
 | 
			
		||||
                #elif _WIN32
 | 
			
		||||
                    // Sleep ist in Milisekunden
 | 
			
		||||
                    Sleep(2 * 1000);
 | 
			
		||||
                #endif
 | 
			
		||||
 | 
			
		||||
                return 20;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (return_code){
 | 
			
		||||
          case 10: { 
 | 
			
		||||
            Tic_Tac_Toe(); 
 | 
			
		||||
 | 
			
		||||
            fflush(stdout);
 | 
			
		||||
            //Sleep
 | 
			
		||||
            #ifdef __linux__
 | 
			
		||||
                sleep(2);
 | 
			
		||||
            #elif _WIN32
 | 
			
		||||
                // Sleep ist in Milisekunden
 | 
			
		||||
                Sleep(2 * 1000);
 | 
			
		||||
            #endif
 | 
			
		||||
 | 
			
		||||
            return_code = 0; 
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case 20: return 20; break; 
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Ramen-vz/Ramen_Physik.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Ramen-vz/Ramen_Physik.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
/* Ramen_Physik.h
 | 
			
		||||
Hier werden Physikaufgaben gelöst mit einem Spiel als Pause
 | 
			
		||||
 | 
			
		||||
Autor: Jana Nieblas
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 15.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 15.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _FILE_NAME_H_ 
 | 
			
		||||
#define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
   //extern Phxsik mit Spiel; 
 | 
			
		||||
   extern int Ramen_Physik();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										187
									
								
								src/Ramen-vz/Tic_Tac_Toe.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								src/Ramen-vz/Tic_Tac_Toe.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,187 @@
 | 
			
		||||
/* Tic Tac Toe
 | 
			
		||||
Ein einfaches Tic Tac Toe programm
 | 
			
		||||
 | 
			
		||||
Autor: Debora Semmler
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version: 1.0
 | 
			
		||||
Datum: 13.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 13.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Einbinden von Headerdateien der Programmbibliothek.
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
//Definition von Spielfeld und Symbolen
 | 
			
		||||
char board[3][3];
 | 
			
		||||
const char PLAYER = 'O';
 | 
			
		||||
const char COMPUTER = 'X';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Funktionsprototypen
 | 
			
		||||
void resetBoard();
 | 
			
		||||
void printBoard();
 | 
			
		||||
int checkFreeSpaces();
 | 
			
		||||
void playerMoves();
 | 
			
		||||
void computerMoves();
 | 
			
		||||
char checkWinner();
 | 
			
		||||
void printWinner(char);
 | 
			
		||||
 | 
			
		||||
//Das Hauptprogramm
 | 
			
		||||
int Tic_Tac_Toe() 
 | 
			
		||||
{
 | 
			
		||||
	printf("Du spielst mit O und der Computer mit X \n \n");
 | 
			
		||||
 | 
			
		||||
	char winner = ' ';
 | 
			
		||||
	
 | 
			
		||||
	resetBoard();
 | 
			
		||||
 | 
			
		||||
	while(winner == ' ' && checkFreeSpaces() != 0)
 | 
			
		||||
	{
 | 
			
		||||
		printBoard();
 | 
			
		||||
 | 
			
		||||
		playerMoves();
 | 
			
		||||
		winner = checkWinner();
 | 
			
		||||
		if(winner != ' ' || checkFreeSpaces() == 0){
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		computerMoves();
 | 
			
		||||
		winner = checkWinner();
 | 
			
		||||
		if(winner != ' ' || checkFreeSpaces() == 0){
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	printBoard();
 | 
			
		||||
	printWinner(winner);
 | 
			
		||||
	
 | 
			
		||||
	// Rückgabewert, dass das Programm erfolgreich beendet wurde.
 | 
			
		||||
	return 0;
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void resetBoard(){
 | 
			
		||||
	for(int i = 0; i<3; i++)
 | 
			
		||||
	{
 | 
			
		||||
		for(int j = 0; j<3; j++)
 | 
			
		||||
		{
 | 
			
		||||
			board[i][j]	= ' ';
 | 
			
		||||
		}	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Gibt das Spielfeld aus
 | 
			
		||||
void printBoard(){
 | 
			
		||||
	printf("[ %c ][ %c ][ %c ]\n", board[0][0], board[0][1], board[0][2]);
 | 
			
		||||
	printf("[ %c ][ %c ][ %c ]\n", board[1][0], board[1][1], board[1][2]);
 | 
			
		||||
	printf("[ %c ][ %c ][ %c ]\n", board[2][0], board[2][1], board[2][2]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Zählt die freien Felder auf dem Spielfeld
 | 
			
		||||
int checkFreeSpaces(){
 | 
			
		||||
	int freeSpaces = 9;	
 | 
			
		||||
 | 
			
		||||
	for(int i = 0; i<3; i++)
 | 
			
		||||
	{
 | 
			
		||||
		for(int j = 0; j<3; j++)
 | 
			
		||||
		{
 | 
			
		||||
			if(board[i][j] != ' ')
 | 
			
		||||
			{
 | 
			
		||||
				freeSpaces--;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return freeSpaces;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Ernöglicht dem Spieler einen Zug zu machen
 | 
			
		||||
void playerMoves(){
 | 
			
		||||
	int x;
 | 
			
		||||
	int y;
 | 
			
		||||
 | 
			
		||||
	do
 | 
			
		||||
	{
 | 
			
		||||
		printf("Gibt die Horizontale ein (1-3): ");
 | 
			
		||||
		scanf("%d", &x);
 | 
			
		||||
		x--;
 | 
			
		||||
		printf("Gib die Vertikale ein (1-3): ");
 | 
			
		||||
		scanf("%d", &y);
 | 
			
		||||
		y--;
 | 
			
		||||
 | 
			
		||||
		if(board[x][y] != ' ')
 | 
			
		||||
		{
 | 
			
		||||
			printf("Ungültig!\n");
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
			board[x][y] = PLAYER;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	} while (board[x][y] != ' ');
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Der Computer macht einen Zufallszug
 | 
			
		||||
void computerMoves(){
 | 
			
		||||
	//Seed für Zufallszahlen
 | 
			
		||||
	srand(time(0));
 | 
			
		||||
	int x;
 | 
			
		||||
	int y;
 | 
			
		||||
 | 
			
		||||
	if(checkFreeSpaces() > 0){
 | 
			
		||||
		do
 | 
			
		||||
		{
 | 
			
		||||
			x = rand() % 3;
 | 
			
		||||
			y = rand() % 3;
 | 
			
		||||
		} while (board[x][y] != ' ');
 | 
			
		||||
 | 
			
		||||
		board[x][y] = COMPUTER;	
 | 
			
		||||
	}
 | 
			
		||||
	else{
 | 
			
		||||
		printWinner(' ');
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Überprüft die Gewinn bedingungen
 | 
			
		||||
char checkWinner(){
 | 
			
		||||
	//Prüft nach horizontalen Gewinnbedingungen
 | 
			
		||||
	for(int i = 0; i < 3; i ++){
 | 
			
		||||
		if(board[i][0] == board[i][1] && board[i][0] == board[i][2]){
 | 
			
		||||
			return board[i][0]; 
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	//Prüft nach vertikalen Gewinnbedingungen
 | 
			
		||||
	for(int i = 0; i < 3; i ++){
 | 
			
		||||
		if(board[0][i] == board[1][i] && board[0][i] == board[2][i]){
 | 
			
		||||
			return board[0][i]; 
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	//Prüft nach diagonalen Gewinnbedingungen
 | 
			
		||||
	if(board[0][0] == board[1][1] && board[0][0] == board[2][2]){
 | 
			
		||||
		return board[0][0]; 
 | 
			
		||||
	}	
 | 
			
		||||
	if(board[0][2] == board[1][1] && board[0][2] == board[2][0]){
 | 
			
		||||
		return board[0][2]; 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ' ';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Gibt das Ergebnis des Spieldurchgangs aus
 | 
			
		||||
void printWinner(char winner){
 | 
			
		||||
	if(winner == PLAYER){
 | 
			
		||||
		printf("DU HAST GEWONNEN!");
 | 
			
		||||
	}
 | 
			
		||||
	else if(winner == COMPUTER){
 | 
			
		||||
		printf("DU HAST VERLOREN!");
 | 
			
		||||
	}
 | 
			
		||||
	else{
 | 
			
		||||
		printf("ES IST EIN UNENTSCHIEDEN!");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Ramen-vz/Tic_Tac_Toe.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Ramen-vz/Tic_Tac_Toe.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
/* Ramen_Physik.h
 | 
			
		||||
Hier wir das Spiel als Pause verknüpft
 | 
			
		||||
 | 
			
		||||
Autor: Jana Nieblas
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 15.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 15.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _FILE_NAME_H_ 
 | 
			
		||||
#define _FILE_NAME_H_ 
 | 
			
		||||
 | 
			
		||||
   //extern Spiel; 
 | 
			
		||||
   extern int Tic_Tac_Toe();
 | 
			
		||||
   
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										351
									
								
								src/Wein-tz/Abbildungsrechner.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										351
									
								
								src/Wein-tz/Abbildungsrechner.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,351 @@
 | 
			
		||||
/* Abbildungsrechner.c
 | 
			
		||||
Disese Programm macht folgendes: 
 | 
			
		||||
1. Wahl zur Berechnung von optischen Messgroessen
 | 
			
		||||
2. Berechnung der gewaehlte Messgroesse
 | 
			
		||||
3. Gibt die Berechnung auf der Konsole aus
 | 
			
		||||
 | 
			
		||||
Autor: Catherine, Mika und Sebastian
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 14.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 14.12.2024 Erste Version
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 ** Eingebundene Bibliotheken			                                     **
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 ** Variablen                                                                **
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
float f, a, A, M, y, Y; //Brennweite, Objektweite, Bildweite, Vergroesserung, Objektgroesse, Bildgroesse
 | 
			
		||||
int P = 0; //Programmauswahl 
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 ** Funktions Prototypen                                                     **
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
void programmAuswahl();
 | 
			
		||||
void Berechnung_Optische_Abbildung(float f, float a, float A, float M, float y, float Y, int P);
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 ** Hauptfunktion                                                            **
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
int Abbildungsrechner()
 | 
			
		||||
{
 | 
			
		||||
    while (P != 10){
 | 
			
		||||
    programmAuswahl();
 | 
			
		||||
    Berechnung_Optische_Abbildung(f, a, A, M, y, Y, P); 
 | 
			
		||||
    }
 | 
			
		||||
    P = 0;
 | 
			
		||||
    return 10;
 | 
			
		||||
}
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 ** Funktionen                                                               **
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
void programmAuswahl()
 | 
			
		||||
{
 | 
			
		||||
    printf("Waehlen Sie die zu berechnende Groesse: \n");
 | 
			
		||||
    printf("1: Brennweite (f)\n");
 | 
			
		||||
    printf("2: Objektweite (a)\n");
 | 
			
		||||
    printf("3: Bildweite (A)\n");
 | 
			
		||||
    printf("4: Objektgroesse (y)\n");
 | 
			
		||||
    printf("5: Bildgroesse (Y)\n");
 | 
			
		||||
    printf("6: Vergroesserung (M)\n");
 | 
			
		||||
    printf("q: zurück zum Menu\n");
 | 
			
		||||
    printf("Geben sie Ihre P ein(1-6):\n ");
 | 
			
		||||
 | 
			
		||||
    char auswahl[21] = {0};
 | 
			
		||||
    long auswahl_int = 0;
 | 
			
		||||
    char *endptr;
 | 
			
		||||
 | 
			
		||||
    scanf("%20s", auswahl);
 | 
			
		||||
    auswahl_int = strtol((const char*)auswahl, &endptr, 10);
 | 
			
		||||
 | 
			
		||||
    if (*endptr != 0){
 | 
			
		||||
        auswahl_int = -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (*endptr == 'q'){
 | 
			
		||||
        P = 10;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    P = auswahl_int;
 | 
			
		||||
 | 
			
		||||
    switch(P)
 | 
			
		||||
    {
 | 
			
		||||
        case 1:
 | 
			
		||||
        printf("Sie haben Programm 1 gewaehlt: Brennweite berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 2:
 | 
			
		||||
        printf("Sie haben Programm 2 gewaehlt: Objektweite berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 3:
 | 
			
		||||
        printf("Sie haben Programm 3 gewaehlt: Bildweite berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 4:
 | 
			
		||||
        printf("Sie haben Programm 4 gewaehlt: Objektgroesse berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 5:
 | 
			
		||||
        printf("Sie haben Programm 5 gewaehlt: Bildgroesse berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 6:
 | 
			
		||||
        printf("Sie haben Programm 6 gewaehlt: Vergroesserung berechnen\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
        printf("Dieses Programm ist ungueltigt.\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
void Berechnung_Optische_Abbildung(float f, float a, float A, float M, float y, float Y, int P)
 | 
			
		||||
{
 | 
			
		||||
    switch (P) {
 | 
			
		||||
 | 
			
		||||
        case 1:     // Berechnung Brennweite [f]
 | 
			
		||||
        printf("Geben Sie Bildweite [A] und Objektweite [a] ein:\n");
 | 
			
		||||
        printf("Bildweite [A]: ");
 | 
			
		||||
        scanf("%f", &A);
 | 
			
		||||
        printf("Objektweite [a]: ");
 | 
			
		||||
        scanf("%f", &a);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Brennweite mit Objektweite [a] und Bildweite [A]
 | 
			
		||||
        f = (a * A) / (A + a);
 | 
			
		||||
        // Berechnung Vergroesserung mit Objektweite (a) und Bildweite [A]
 | 
			
		||||
        M = -(A / a);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Brennweite [f]:\n%f", f);
 | 
			
		||||
        printf("\nVergroesserung [M]:\n%f", M);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("f = (a * A) / (A + a)\n");
 | 
			
		||||
        printf("M = (A / a)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 2:     // Berechnung Objektweite [a]
 | 
			
		||||
        printf("Waehlen Sie die Berechnungsmethode:\n");
 | 
			
		||||
        printf("1: Mit Bildweite [A] und Brennweite [f]\n");
 | 
			
		||||
        printf("2: Mit Bildgroesse [Y] und Objektgroesse [y]\n");
 | 
			
		||||
        scanf("%d", &P);
 | 
			
		||||
 | 
			
		||||
        if (P == 1) {
 | 
			
		||||
        printf("Geben Sie Bildweite [A] und Brennweite [f] ein:\n");
 | 
			
		||||
        printf("Bildweite [A]: ");
 | 
			
		||||
        scanf("%f", &A );
 | 
			
		||||
        printf("Brennweite [f]: ");
 | 
			
		||||
        scanf("%f", &f);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Objektweite [a] mit Bildweite [A] und Brennweite [f]
 | 
			
		||||
        a = (f * A) / (A - f);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Objektweite [a]:\n%f", a);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("a = (f * A) / (A - f)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        else if (P == 2) {
 | 
			
		||||
        printf("Geben Sie Bildgroesse [Y] und Objektgroesse [y] ein:\n");
 | 
			
		||||
        printf("Bildgroesse [Y]: ");
 | 
			
		||||
        scanf("%f", &Y);
 | 
			
		||||
        printf("Objektgroesse [y]: ");
 | 
			
		||||
        scanf("%f", &y);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Objektweite [a] mit Bildweite [A] und Vergroesserung (M) 
 | 
			
		||||
        a = -(A / M);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Objektweite [a]:\n%f", a);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("a = a(A / M)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 3:     // Berechnung Bildweite [A]
 | 
			
		||||
        printf("Waehlen Sie die Berechnungsmethode:\n");
 | 
			
		||||
        printf("1: Mit Objektweite [a] und Brennweite [f]\n");
 | 
			
		||||
        printf("2: Mit Objektweite [a] und Vergroesserung [M]\n");
 | 
			
		||||
        scanf("%d", &P);
 | 
			
		||||
 | 
			
		||||
        if (P == 1) {
 | 
			
		||||
        printf("Geben Sie Objektweite [a] und Brennweite [f] ein:\n");
 | 
			
		||||
        printf("Objektweite [a]: ");
 | 
			
		||||
        scanf("%f", &a);
 | 
			
		||||
        printf("Brennweite [f]: ");
 | 
			
		||||
        scanf("%f", &f);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Bildweite [A] mit Brennweite [f] und Objektweite [a]
 | 
			
		||||
        A = (f * a) / (a - f);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Bildweite [A]:\n%f", A);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("A = (f * a) / (a - f)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        } 
 | 
			
		||||
        else if (P == 2) {
 | 
			
		||||
        printf("Geben Sie Vergroesserung [M] und Objektweite [a] ein:\n");
 | 
			
		||||
        printf("Vergroesserung [M]: ");
 | 
			
		||||
        scanf("%f", &M);
 | 
			
		||||
        printf("Objektweite [a]");
 | 
			
		||||
        scanf("%f", &a);  
 | 
			
		||||
 | 
			
		||||
        // Berechnung Bildweite [A] mit Vergroesserung [M] und Objektweite [a]
 | 
			
		||||
        A = -(a * M);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Bildweite [A]:\n%f", A);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("A = -(a * M)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 4:     // Berechnung Objektgroesse [y]
 | 
			
		||||
 | 
			
		||||
        printf("Waehlen Sie die Berechnungsmethode:\n");
 | 
			
		||||
        printf("1: Mit Bildweite [A], Objektweite [a] und Bildgroesse [y]\n");
 | 
			
		||||
        printf("2: Mit Bildgroesse [Y] und Vergroesserung [M]\n");
 | 
			
		||||
        scanf("%d", &P);
 | 
			
		||||
 | 
			
		||||
        if (P == 1) {
 | 
			
		||||
        printf("Geben Sie Bildweite [A] und Objektweite [a] ein:\n");
 | 
			
		||||
        printf("Bildweite [A]: ");
 | 
			
		||||
        scanf("%f", &A);
 | 
			
		||||
        printf("Objektweite [a]: ");
 | 
			
		||||
        scanf("%f", &a); 
 | 
			
		||||
 | 
			
		||||
        // Berechnung Objektgroesse [y] mit Bildweite [A] und Objektweite [a] und Bildgroesse [y]
 | 
			
		||||
        y = -(Y * A) / a;
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Objektgroesse [y]:\n%f", y);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("a = -(Y * A) / a\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        else if (P == 2) {
 | 
			
		||||
        printf("Geben Sie Bildgroesse [Y] und Vergroesserung [M] ein:\n");
 | 
			
		||||
        printf("Bildgroesse [Y]: ");
 | 
			
		||||
        scanf("%f", &Y);
 | 
			
		||||
        printf("Vergroesserung[M]: ");
 | 
			
		||||
        scanf("%f", &M);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Objektgroesse [y] mit Bildgroesse [Y] und Vergroesserung [M]
 | 
			
		||||
        y = Y / M;
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Objektgroesse [y]:\n%f", y);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("y = Y / M\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 5:     // Berechnung Bildgroesse [Y]
 | 
			
		||||
        printf("Waehlen Sie die Berechnungsmethode:\n");
 | 
			
		||||
        printf("1: Mit Bildweite [A], Objektweite [a] und Objektgroesse [y]\n");
 | 
			
		||||
        printf("2: Mit Bildgroesse [Y] und Vergroesserung [M]\n");
 | 
			
		||||
        scanf("%d", &P);
 | 
			
		||||
 | 
			
		||||
        if (P == 1) {
 | 
			
		||||
        printf("Geben Sie Bildweite [A], Objektweite [a] und Objektgroesse [y] ein:\n");
 | 
			
		||||
        printf("Bildweite [A]: ");
 | 
			
		||||
        scanf("%f", &A);
 | 
			
		||||
        printf("Objektweite [a]: ");
 | 
			
		||||
        scanf("%f", &a);
 | 
			
		||||
        printf("Objektgroesse [y]: ");
 | 
			
		||||
        scanf("%f", &y); 
 | 
			
		||||
 | 
			
		||||
        // Berechnung Bildgroesse [Y] mit Objektweite [a] und Bildweite [A] und Objektgroesse [y]
 | 
			
		||||
        Y = -(A / a) * y;
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Bildgroesse [Y]:\n%f", Y);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("\nY = -(A / a) * y\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        } 
 | 
			
		||||
        else if (P == 2) {
 | 
			
		||||
        printf("Geben Sie Bildgroesse [Y] und Vergroesserung [M] ein:\n");
 | 
			
		||||
        printf("Bildgroesse [Y]: ");
 | 
			
		||||
        scanf("%f", &Y);
 | 
			
		||||
        printf("Vergroesserung [M]: ");
 | 
			
		||||
        scanf("%f", &M);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Bildgroesse [Y] mit Vergroesserung [M] und Objektgroesse [y]
 | 
			
		||||
        Y = y * M;
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Bildgroesse [Y]:\n%f", Y);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("Y = y * M\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
        case 6:     // Berechnung Vergroesserung [M]
 | 
			
		||||
        printf("Waehlen Sie die Berechnungsmethode:\n");
 | 
			
		||||
        printf("1: Mit Bildweite [A] und Objektweite [a]\n");
 | 
			
		||||
        printf("2: Mit Bildgroesse [Y] und Objektgroesse [y]\n");
 | 
			
		||||
        scanf("%d", &P);
 | 
			
		||||
 | 
			
		||||
        if (P == 1) {
 | 
			
		||||
        printf("Geben Sie Bildweite [A] und Objektweite [a] ein:\n");
 | 
			
		||||
        printf("Bildweite [A]: ");
 | 
			
		||||
        scanf("%f", &A);
 | 
			
		||||
        printf("Objektweite [a]: ");
 | 
			
		||||
        scanf("%f", &a);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Vergroesserung [M] mit Objektweite [a] und Bildweite [A]
 | 
			
		||||
        M = -(A / a);
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Vergroesserung [M]\n%f", M);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("M = -(A / a)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        else if (P == 2) {
 | 
			
		||||
        printf("Geben Sie Bildgroesse [Y] und Objektgroesse [y] ein:\n");
 | 
			
		||||
        printf("Bildgroeße [Y]: ");
 | 
			
		||||
        scanf("%f", &Y);
 | 
			
		||||
        printf("Objektgroesse [y]: ");
 | 
			
		||||
        scanf("%f", &y);
 | 
			
		||||
 | 
			
		||||
        // Berechnung Vergroesserung [M] mit Objektgroesse [y] und Bildgroesse [Y]
 | 
			
		||||
        M = (Y / y); 
 | 
			
		||||
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        printf("Vergroesserung [M]\n%f", M);
 | 
			
		||||
 | 
			
		||||
        printf("\n-----------------------\n");
 | 
			
		||||
        printf("M = (Y /y)\n");
 | 
			
		||||
        printf("-----------------------\n");
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										19
									
								
								src/Wein-tz/Abbildungsrechner.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/Wein-tz/Abbildungsrechner.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
/* Abbildungsrechner.h
 | 
			
		||||
Dies ist die Verknüpfung zum Abbildungsrechner
 | 
			
		||||
 | 
			
		||||
Autor: Catherine, Sebastian, Mika
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 16.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 16.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _Abbildungsrechner_H_ 
 | 
			
		||||
#define _Abbildungsrechner_H_ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    int Abbildungsrechner();
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										174
									
								
								src/Wein-vz/InformatikZusammenfassung.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								src/Wein-vz/InformatikZusammenfassung.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,174 @@
 | 
			
		||||
/* InformatikZusammenfassung.c
 | 
			
		||||
Programm das einen Text auf die Konsole ausgibt
 | 
			
		||||
Autor: Giulia Benz
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version: 0.1
 | 
			
		||||
Datum: 11.12.2024
 | 
			
		||||
Änderungen:
 | 
			
		||||
0.1 11.12.2024 Erste Version
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Einbinden von Headerdateien der Programmbibliothek.
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
//Start unseres Programms
 | 
			
		||||
int Informatik_main(void) {
 | 
			
		||||
 | 
			
		||||
    int j = 1;
 | 
			
		||||
    int work = 0;
 | 
			
		||||
 | 
			
		||||
    char auswahl[21] = {0};
 | 
			
		||||
    long auswahl_int = 0;
 | 
			
		||||
    char *endptr;
 | 
			
		||||
 | 
			
		||||
    while (auswahl_int != 99)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        printf("Waehlen Sie bitte einen Befehl aus oder geben Sie 99 zum Stoppen en ein\n");
 | 
			
		||||
        printf("-1- \t printf \n");
 | 
			
		||||
        printf("-2- \t \\ \n");
 | 
			
		||||
        printf("-3- \t \\n \n");
 | 
			
		||||
        printf("-4- \t %%d \n");
 | 
			
		||||
        printf("-5- \t Sizeof\n");
 | 
			
		||||
        printf("-6- \t \"string\" \n");
 | 
			
		||||
        printf("-7- \t signed char Sie tun: \n");
 | 
			
		||||
        printf("-8- \t short\n");
 | 
			
		||||
        printf("-9- \t int\n");
 | 
			
		||||
        printf("-10- \t long\n");
 | 
			
		||||
        printf("-11- \t long long\n");
 | 
			
		||||
        printf("-12- \t char\n");
 | 
			
		||||
        printf("-13- \t float\n");
 | 
			
		||||
        printf("-14- \t double\n");
 | 
			
		||||
        printf("-15- \t long double\n");
 | 
			
		||||
        printf("-16- \t const\n");
 | 
			
		||||
        printf("-17- \t scanf\n");
 | 
			
		||||
        printf("-18- \t if\n");
 | 
			
		||||
        printf("-19- \t else\n");
 | 
			
		||||
        printf("-20- \t else if\n");
 | 
			
		||||
        printf("-21- \t switch\n");
 | 
			
		||||
        printf("-22- \t for\n");
 | 
			
		||||
        printf("-23- \t while\n");
 | 
			
		||||
        printf("-24- \t do while\n");
 | 
			
		||||
        printf("-25- \t *\n");
 | 
			
		||||
        printf("-26- \t Array\n");
 | 
			
		||||
        printf("-27- \t String\n");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        scanf("%20s", auswahl);
 | 
			
		||||
        auswahl_int = strtol((const char*)auswahl, &endptr, 10);
 | 
			
		||||
 | 
			
		||||
        if (*endptr != 0){
 | 
			
		||||
            auswahl_int = -1;
 | 
			
		||||
        }
 | 
			
		||||
        if (*endptr == 'q'){
 | 
			
		||||
        return 10;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*  unötig → case default
 | 
			
		||||
        if( scanf("%i", &work) != 1 )
 | 
			
		||||
        {
 | 
			
		||||
            printf("Fehler bei der Eingabe...\n");
 | 
			
		||||
        }
 | 
			
		||||
        printf("\n\n");
 | 
			
		||||
        */
 | 
			
		||||
 | 
			
		||||
        switch(auswahl_int){
 | 
			
		||||
            case 1 : printf("Zeichentexte(strings) auf Konsole ausgeben\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 2: printf("Abstand innerhalb des Printf (\t steht für 4 oder 8 mal abstand drücken)\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 3: printf("Zeilenumbruch\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 4: printf("Platzhalter fuer eine Zahl\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 5: printf("Speicherbedarf ermitteln\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 6: printf("Zeichenliteral, was in printf steht\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 7: printf("Datentyp von -128 bis +127, hierbei sind die Formatzeichen %%hhd fuer dezimal und %%c fuer Zeichen\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 8: printf("Datentyp von -32768 bis 32768 mit Formatzeichen %%hd oder %%hi \n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 9: printf("Datentyp von -32768 bis 32768 mit Formatzeichen %%d oder %%i\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 10: printf("Datentyp von -2.147.483.648 bis -2.147.483.648 mit Formatzeichen %%ld oder %%li\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 11: printf("Datentyp von -9.223.372.036.854.775.808 bis 9.223.372.036.854.775.808 mit Formatzeichen %%lld oder %%11i \n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 12: printf("grundlegender Datentyp für Zeichen (nur 1 Byte Speicherplatz)\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 13: printf("Suffix für bis zu 7 Dezimalstellen -> %%f\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 14: printf("Suffix für bis zu 15-16 Dezimalstellen -> %%f (für printf %%lf)\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 15: printf("Suffix für bis mehr al 19 Dezimalstellen -> %%Lf\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 16: printf("Konstante = dasselbe wie Variable aber nicht veränderbar während dem Programm\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 17: printf("Etwas in Konsole eingeben\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 18: printf("bedingte Answeisung\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 19: printf("Nach if was es sonst machen soll\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 20: printf("Mischung von else und if\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 21: printf("Mehrfachverzweigung\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 22: printf("Zählerschleife\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 23: printf("Schleife\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 24: printf("Schleife, wenn man Dinge mehrmals ausführen muss (oder auch nur einmal)\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 25: printf("Pointer, zeigt auf etwas und gibt aus was in der Variable steht, aber verändert sie nicht\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 26: printf("Ansamlung von Elementen\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 27: printf("dasselbe wie Array mit Buchstaben\n");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case 99: printf("hoffentlech hei mer der choene helfe ");
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            default: printf("%li falsche Eingabe\n", auswahl_int);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (auswahl_int != 99)
 | 
			
		||||
        {
 | 
			
		||||
            printf("\n\n0 => Menu\n");
 | 
			
		||||
            scanf("%20li", &auswahl_int);
 | 
			
		||||
            fflush(stdin);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								src/Wein-vz/InformatikZusammenfassung.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/Wein-vz/InformatikZusammenfassung.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
/* Abbildungsrechner.h
 | 
			
		||||
Dies ist die Verknüpfung zum Abbildungsrechner
 | 
			
		||||
 | 
			
		||||
Autor: Catherine, Sebastian, Mika
 | 
			
		||||
Firma: FHGR
 | 
			
		||||
Version 1.0
 | 
			
		||||
Datum 16.12.2024
 | 
			
		||||
Aenderungen:
 | 
			
		||||
V 1.0 16.12.2024 Erste Version
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _INFORMATIKZUSAMMENFASSUNG_H_ 
 | 
			
		||||
#define _INFORMATIKZUSAMMENFASSUNG_H_ 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    int Informatik_main();
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										299
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										299
									
								
								src/main.c
									
									
									
									
									
								
							@ -1,19 +1,3 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
    #include <sys/ioctl.h>
 | 
			
		||||
    #include <unistd.h>
 | 
			
		||||
    #include <termio.h>
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// import sub programme
 | 
			
		||||
#include "pipes_test.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Photonics helper main programm
 | 
			
		||||
Das main programm startet die sub programme der verschienene gruppen
 | 
			
		||||
@ -25,10 +9,45 @@ Datum: 04.12.2024
 | 
			
		||||
0.1 04.12.2024 Dokument erstellt
 | 
			
		||||
0.2 09.12.2024 Willkommensnachricht
 | 
			
		||||
0.3 10.12.2024 Meun hinzugefügt
 | 
			
		||||
0.4 11.12.2024 pipes + easter eggs hinzugefügt
 | 
			
		||||
0.5 12.12.2024 Windows version fix
 | 
			
		||||
0.6 13.12.2024 Pfeiltasten wurden hinzugefügt
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
    #include <sys/ioctl.h>
 | 
			
		||||
    #include <unistd.h>
 | 
			
		||||
    #include <termio.h>
 | 
			
		||||
    #include "Main-vz/kbhit_linux.h"
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
    #include <windows.h>
 | 
			
		||||
    #include <conio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// import sub programme
 | 
			
		||||
#include "Ramen-vz/Ramen_Physik.h"
 | 
			
		||||
#include "Fehlenden-vz/Fehlenden_Elektronik.h"
 | 
			
		||||
#include "Flugi-tz/Funktion_Flugi.h"
 | 
			
		||||
#include "Flugi-vz/Rechner_Wellenlaenge2.h"
 | 
			
		||||
#include "Wein-tz/Abbildungsrechner.h"
 | 
			
		||||
#include "Wein-vz/InformatikZusammenfassung.h"
 | 
			
		||||
#include "Haenchen-vz/Haenchen_Drehmoment.h"
 | 
			
		||||
#include "test_prog.h"
 | 
			
		||||
 | 
			
		||||
#include "Main-vz/pipes_test.h"
 | 
			
		||||
#include "Main-vz/pipes2.h"
 | 
			
		||||
#include "Main-vz/pipes2_game.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
int getch(){ 
 | 
			
		||||
    // getch funktion für linux (für windows in der conio.h lib)
 | 
			
		||||
    int ch;
 | 
			
		||||
    struct termios oldattr, newattr;
 | 
			
		||||
 | 
			
		||||
@ -54,7 +73,6 @@ void get_terminal_size_linux(int argc, char **argv, int *width, int *height){
 | 
			
		||||
    *height = w.ws_row;
 | 
			
		||||
    *width = w.ws_col;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#elif _WIN32
 | 
			
		||||
void get_terminal_size_windows(int argc, char **argv, int *width, int *height){
 | 
			
		||||
    CONSOLE_SCREEN_BUFFER_INFO csbi;
 | 
			
		||||
@ -67,30 +85,28 @@ void get_terminal_size_windows(int argc, char **argv, int *width, int *height){
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void print_line(char line[100], int spaces, char color[5]){
 | 
			
		||||
    // funktion welche den text in einer farbe und mit space printet
 | 
			
		||||
    for(int i = 0; i < spaces; i++){
 | 
			
		||||
        printf(" ");
 | 
			
		||||
    }
 | 
			
		||||
    printf("\033[1%sm %s \033[0m\n", color, line);
 | 
			
		||||
    // printf("%s\n", line);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void clear_terminal(){
 | 
			
		||||
    #ifdef __linux__
 | 
			
		||||
        printf("\e[1;1H\e[2J");
 | 
			
		||||
    #elif _WIN32
 | 
			
		||||
        system("cls");
 | 
			
		||||
    #endif
 | 
			
		||||
    printf("\e[1;1H\e[2J");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void sleep_universal(int t){
 | 
			
		||||
    #ifdef __linux__
 | 
			
		||||
        sleep(t);
 | 
			
		||||
    #elif _WIN32
 | 
			
		||||
        // Sleep ist in Milisekunden
 | 
			
		||||
        Sleep(t * 1000);
 | 
			
		||||
    #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_blank_lines(int lines){
 | 
			
		||||
    // funktion die leere zeilen printet
 | 
			
		||||
    for(int i = 0; i < lines; i++){
 | 
			
		||||
        printf("\n");
 | 
			
		||||
    }
 | 
			
		||||
@ -115,20 +131,6 @@ void print_wellcome(int terminal_width, int terminal_height){
 | 
			
		||||
    print_line("|_|   |_| |_|\\___/ \\__|_| |_|\\___/|_| |_|_|\\___|___/   |_| |_|\\___|_|_|  \\___|_|     ", spaces, ";37");
 | 
			
		||||
 | 
			
		||||
    sleep_universal(2);
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    printf("__        ___ _ _ _                                                                ");
 | 
			
		||||
    printf("\ \      / (_) | | | _____  _ __ ___  _ __ ___   ___ _ __      _____   _ _ __ ___  ");
 | 
			
		||||
    printf(" \ \ /\ / /| | | | |/ / _ \| '_ ` _ \| '_ ` _ \ / _ \ '_ \    |_  / | | | '_ ` _ \ ");
 | 
			
		||||
    printf("  \ V  V / | | | |   < (_) | | | | | | | | | | |  __/ | | |    / /| |_| | | | | | |");
 | 
			
		||||
    printf("   \_/\_/  |_|_|_|_|\_\___/|_| |_| |_|_| |_| |_|\___|_| |_|   /___|\__,_|_| |_| |_|");
 | 
			
		||||
    printf("                                                                                   ");
 | 
			
		||||
    printf(" ____  _           _   _                 _              _   _      _  __           ");
 | 
			
		||||
    printf("|  _ \| |__   ___ | |_| |__   ___  _ __ (_) ___ ___    | | | | ___| |/ _| ___ _ __ ");
 | 
			
		||||
    printf("| |_) | '_ \ / _ \| __| '_ \ / _ \| '_ \| |/ __/ __|   | |_| |/ _ \ | |_ / _ \ '__|");
 | 
			
		||||
    printf("|  __/| | | | (_) | |_| | | | (_) | | | | | (__\__ \   |  _  |  __/ |  _|  __/ |   ");
 | 
			
		||||
    printf("|_|   |_| |_|\___/ \__|_| |_|\___/|_| |_|_|\___|___/   |_| |_|\___|_|_|  \___|_|   ");
 | 
			
		||||
    */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_game_over(int terminal_width, int terminal_height){
 | 
			
		||||
@ -145,26 +147,61 @@ void print_game_over(int terminal_width, int terminal_height){
 | 
			
		||||
    print_blank_lines(2);
 | 
			
		||||
    print_line("Press a key to contine: ", spaces, ";37");
 | 
			
		||||
    char key_input = (char)getch();
 | 
			
		||||
    // getchar();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_speedrun(int terminal_width, int terminal_height, int speed_time){
 | 
			
		||||
    clear_terminal();
 | 
			
		||||
    print_blank_lines((terminal_height - 12) / 2);
 | 
			
		||||
    int spaces = (terminal_width - 70) / 2;
 | 
			
		||||
 | 
			
		||||
    print_line("    _    ____ _   _ ___ _______     _______ __  __ _____ _   _ _____        ", spaces, ";37");
 | 
			
		||||
    print_line("   / \\  / ___| | | |_ _| ____\\ \\   / / ____|  \\/  | ____| \\ | |_   _|  ", spaces, ";37");
 | 
			
		||||
    print_line("  / _ \\| |   | |_| || ||  _|  \\ \\ / /|  _| | |\\/| |  _| |  \\| | | |(_) ", spaces, ";37");
 | 
			
		||||
    print_line(" / ___ \\ |___|  _  || || |___  \\ V / | |___| |  | | |___| |\\  | | | _    ", spaces, ";37");
 | 
			
		||||
    print_line("/_/   \\_\\____|_| |_|___|_____|  \\_/  |_____|_|  |_|_____|_| \\_| |_|(_)  ", spaces, ";37");
 | 
			
		||||
    print_line("                                                                            ", spaces, ";37");
 | 
			
		||||
    print_line(" ____  ____  _____ _____ ____  ____  _   _ _   _ _   _ _____ ____           ", spaces, ";37");
 | 
			
		||||
    print_line("/ ___||  _ \\| ____| ____|  _ \\|  _ \\| | | | \\ | | \\ | | ____|  _ \\    ", spaces, ";37");
 | 
			
		||||
    print_line("\\___ \\| |_) |  _| |  _| | | | | |_) | | | |  \\| |  \\| |  _| | |_) |     ", spaces, ";37");
 | 
			
		||||
    print_line(" ___) |  __/| |___| |___| |_| |  _ <| |_| | |\\  | |\\  | |___|  _ <        ", spaces, ";37");
 | 
			
		||||
    print_line("|____/|_|   |_____|_____|____/|_| \\_\\\\___/|_| \\_|_| \\_|_____|_| \\_\\  ", spaces, ";37");
 | 
			
		||||
 | 
			
		||||
    print_blank_lines(2);
 | 
			
		||||
    print_line("", spaces, ";37");
 | 
			
		||||
    printf("Du brauchtest: %i Sekunden.", speed_time);
 | 
			
		||||
    char key_input = (char)getch();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_menu(int terminal_width, int terminal_height, int line){
 | 
			
		||||
    clear_terminal();
 | 
			
		||||
    print_blank_lines((terminal_height - 11) / 2);
 | 
			
		||||
    printf("Drücke ? für Hilfe\n");
 | 
			
		||||
    print_blank_lines((terminal_height - 23) / 2);
 | 
			
		||||
    int spaces = (terminal_width - 41) / 2;
 | 
			
		||||
 | 
			
		||||
        print_line("╔═══════════════════════════════════════╗", spaces, ";34");
 | 
			
		||||
        print_line("║  Photonics Helfer                     ║", spaces, ";34");
 | 
			
		||||
        print_line("╚═══════════════════════════════════════╝", spaces, ";34");
 | 
			
		||||
        printf("\n");
 | 
			
		||||
 | 
			
		||||
        print_line("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  Programm 1                           ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  1 Physik                        (vz) ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (0 <= line && line < 2) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  Programm 2                           ┃", spaces, (1 <= line && line < 2) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  2 Elektronik                    (vz) ┃", spaces, (1 <= line && line < 2) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (1 <= line && line < 3) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  Programm 3                           ┃", spaces, (2 <= line && line < 3) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  3 Informatik                    (vz) ┃", spaces, (2 <= line && line < 3) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  Programm 4                           ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  4 Drehmoment                    (vz) ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
			
		||||
        print_line("┃                                       ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
			
		||||
        print_line("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  5 Wellenlängenrechner           (vz) ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (4 <= line && line < 6) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  6 Abbildungsrechner             (tz) ┃", spaces, (5 <= line && line < 6) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (5 <= line && line < 7) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  7 Quiz                          (tz) ┃", spaces, (6 <= line && line < 7) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (6 <= line && line < 8) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  8                               (tz) ┃", spaces, (7 <= line && line < 8) ? ";31": ";37");
 | 
			
		||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (7 <= line && line < 9) ? ";31": ";37");
 | 
			
		||||
        print_line("┃  9                               (tz) ┃", spaces, (8 <= line && line < 9) ? ";31": ";37");
 | 
			
		||||
        print_line("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", spaces, (8 <= line && line < 9) ? ";31": ";37");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -176,10 +213,10 @@ void print_help(){
 | 
			
		||||
    printf("j \t Ein Programm nach unten\n");
 | 
			
		||||
    printf("k \t Ein Programm nach oben\n");
 | 
			
		||||
    printf("Enter \t Um das ausgewählte Programm zu starten\n");
 | 
			
		||||
    printf("1 - 9 \t Um das n Programm zu starten\n");
 | 
			
		||||
    printf("q \t Um das Programm zu beenden\n");
 | 
			
		||||
    printf("\nDrücke eine Taste um zurück zu kommen\n");
 | 
			
		||||
    char key_input = (char)getch();
 | 
			
		||||
    // getchar();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void get_terminal_size(int argc, char **argv, int *width, int *height){
 | 
			
		||||
@ -188,7 +225,6 @@ void get_terminal_size(int argc, char **argv, int *width, int *height){
 | 
			
		||||
        #elif _WIN32
 | 
			
		||||
            get_terminal_size_windows(argc, argv, width, height);
 | 
			
		||||
        #endif
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void get_terminal_size_init(int argc, char **argv, int *width, int *height){
 | 
			
		||||
@ -205,11 +241,66 @@ void get_terminal_size_init(int argc, char **argv, int *width, int *height){
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void run_programm(int programm, int width, int height, bool *used){
 | 
			
		||||
    clear_terminal();
 | 
			
		||||
    int return_code = 0;
 | 
			
		||||
    switch (programm) {
 | 
			
		||||
        case 0: return_code = Ramen_Physik(); break;
 | 
			
		||||
        case 1: return_code = Fehlenden_Elektronik_main(); break;
 | 
			
		||||
        case 2: return_code = Informatik_main(); break;
 | 
			
		||||
        case 3: return_code = Haenchen_Drehmoment_main(); break;
 | 
			
		||||
        case 4: return_code = Wellenlaengen_rechner_main(); break;
 | 
			
		||||
        case 5: return_code = Abbildungsrechner(); break;
 | 
			
		||||
        case 6: return_code = Flugi(); break;
 | 
			
		||||
        case 7: return_code = test_gruppe_programmname(); break;
 | 
			
		||||
        case 8: return_code = test_gruppe_programmname(); break;
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
    // ist dazu da um "\n" aus dem buffer zu entfernen!
 | 
			
		||||
    int c;
 | 
			
		||||
    while ((c = getchar()) != '\n' && c != EOF) { }
 | 
			
		||||
    // getchar();
 | 
			
		||||
 | 
			
		||||
    switch (return_code) {
 | 
			
		||||
        case 10: used[programm] = 1; break;
 | 
			
		||||
        case 20: print_game_over(width, height); break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void speed(int width, int height, int *start_time, bool *used){
 | 
			
		||||
    if (*start_time + 30 < time(0)){
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    for (int i = 0; i < 6; i++){
 | 
			
		||||
        if (used[i] == 0){
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    int speed_time = time(0) - *start_time;
 | 
			
		||||
    *start_time -= 20;
 | 
			
		||||
    print_speedrun(width, height, speed_time);
 | 
			
		||||
    printf("speed: %i", speed_time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void open(){
 | 
			
		||||
    #ifdef __linux__
 | 
			
		||||
        system("xdg-open https://media1.tenor.com/m/xTZp3_9gnE0AAAAd/linux-linux-convention.gif");
 | 
			
		||||
    #elif _WIN32
 | 
			
		||||
        system("start msedge.exe --kiosk https://www.ravbug.com/bsod/bsod10/ --edge-kiosk-type=fullscreen");
 | 
			
		||||
    #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv){
 | 
			
		||||
    int width = 0;
 | 
			
		||||
    int height = 0;
 | 
			
		||||
    int line = 0;
 | 
			
		||||
    bool run = true;
 | 
			
		||||
    bool *used = (bool[6]){0};
 | 
			
		||||
    int start_time = time(0);
 | 
			
		||||
    bool arrows = true;
 | 
			
		||||
        if (argc >= 2 && strcmp(argv[1], "--ich-benutze-windows-und-bin-auf-die-pfeiltasten-angewiesen") == 0){
 | 
			
		||||
            arrows = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    // umlaute für windows
 | 
			
		||||
    #ifdef _WIN32
 | 
			
		||||
@ -222,27 +313,43 @@ int main(int argc, char **argv){
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    // Terminal grösse herauslesen
 | 
			
		||||
    // get_terminal_size(argc, argv, &width, &height);
 | 
			
		||||
    get_terminal_size_init(argc, argv, &width, &height);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // int x = test_gruppe_programmname();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    printf ("lines %d\n", height);
 | 
			
		||||
    printf ("columns %d\n", width);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // print wellcome message
 | 
			
		||||
    print_wellcome(width, height);
 | 
			
		||||
    // print_game_over(width, height);
 | 
			
		||||
    // print_menu(width, height, line);
 | 
			
		||||
    
 | 
			
		||||
    // Hauptschleife
 | 
			
		||||
    while(run){
 | 
			
		||||
        // liest die terminal grösse ein
 | 
			
		||||
        get_terminal_size_init(argc, argv, &width, &height);
 | 
			
		||||
        print_menu(width, height, line);
 | 
			
		||||
        char key_input = (char)getch();
 | 
			
		||||
 | 
			
		||||
        // zeigt das menu an
 | 
			
		||||
        print_menu(width, height, line);
 | 
			
		||||
 | 
			
		||||
        // liest die Tastatur aus
 | 
			
		||||
        // char key_input = (char)getch();
 | 
			
		||||
 | 
			
		||||
        // timer updateten
 | 
			
		||||
        int last_input = time(0);
 | 
			
		||||
 | 
			
		||||
        while (!kbhit()){
 | 
			
		||||
            if (last_input + 60 <= time(0)){
 | 
			
		||||
                pipes_2(width, height);
 | 
			
		||||
                last_input = time(0);
 | 
			
		||||
                print_menu(width, height, line);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        #ifdef __linux__
 | 
			
		||||
            char key_input = (char)getchar();
 | 
			
		||||
        #elif _WIN32
 | 
			
		||||
            char key_input = (char)getch();
 | 
			
		||||
        #endif
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // verarbeitet die Tastatur eingabe
 | 
			
		||||
        switch (key_input) {
 | 
			
		||||
            // vim movement
 | 
			
		||||
            case 'k': line--; break;
 | 
			
		||||
            case 'j': line++; break;
 | 
			
		||||
            case 'g': {
 | 
			
		||||
@ -252,20 +359,70 @@ int main(int argc, char **argv){
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case 'G': line = 4; break;
 | 
			
		||||
 | 
			
		||||
            case '?': print_help(); break;
 | 
			
		||||
            case 'p': pipes(); break;
 | 
			
		||||
            
 | 
			
		||||
            case 'G': line = 8; break;
 | 
			
		||||
            case 'q': run = false; break;
 | 
			
		||||
            case '\n': printf(" Es wurde die Enter Taste gedrückt"); getchar(); break;
 | 
			
		||||
            default: printf(" Es wurde die Taste: %c gedrückt", key_input);
 | 
			
		||||
            case '?': print_help(); break;
 | 
			
		||||
 | 
			
		||||
            case 'p': pipes(width, height); break;
 | 
			
		||||
            case 'P': pipes_2(width, height); break;
 | 
			
		||||
            case 'o': pipes_2_game(width, height); break;
 | 
			
		||||
 | 
			
		||||
            // windows
 | 
			
		||||
            case -32:{
 | 
			
		||||
                key_input = (char)getch();
 | 
			
		||||
                if (arrows){
 | 
			
		||||
                    switch (key_input){
 | 
			
		||||
                        case 72: line--; break; // printf("up\n");
 | 
			
		||||
                        case 80: line++; break; // printf("down\n");
 | 
			
		||||
                        // case 77: printf("right\n"); break;
 | 
			
		||||
                        // case 75: printf("left\n"); break;
 | 
			
		||||
                    }
 | 
			
		||||
                } else{
 | 
			
		||||
                    open();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            // linux
 | 
			
		||||
            case 27:{
 | 
			
		||||
                key_input = (char)getch();
 | 
			
		||||
                key_input = (char)getch();
 | 
			
		||||
                if (arrows){
 | 
			
		||||
                    switch (key_input){
 | 
			
		||||
                        case 65: line--; break; // printf("up\n");
 | 
			
		||||
                        case 66: line++; break; // printf("down\n");
 | 
			
		||||
                        // case 67: printf("right\n"); break;
 | 
			
		||||
                        // case 68: printf("left\n"); break;
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    open();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // enter unter linux
 | 
			
		||||
            case '\n': run_programm(line, width, height, used); break;
 | 
			
		||||
            // enter under windows
 | 
			
		||||
            case 13 : run_programm(line, width, height, used); break;
 | 
			
		||||
 | 
			
		||||
            // schnell start
 | 
			
		||||
            case '1': run_programm(0, width, height, used); break;
 | 
			
		||||
            case '2': run_programm(1, width, height, used); break;
 | 
			
		||||
            case '3': run_programm(2, width, height, used); break;
 | 
			
		||||
            case '4': run_programm(3, width, height, used); break;
 | 
			
		||||
            case '5': run_programm(4, width, height, used); break;
 | 
			
		||||
            case '6': run_programm(5, width, height, used); break;
 | 
			
		||||
            case '7': run_programm(6, width, height, used); break;
 | 
			
		||||
            case '8': run_programm(7, width, height, used); break;
 | 
			
		||||
            case '9': run_programm(8, width, height, used); break;
 | 
			
		||||
            
 | 
			
		||||
            default: printf(" Es wurde die Taste: %i gedrückt\n", key_input); // getch();
 | 
			
		||||
        }
 | 
			
		||||
        if(line < 0){line = 4;}
 | 
			
		||||
        if(line > 4){line = 0;}
 | 
			
		||||
        // print_menu(width, height, line);
 | 
			
		||||
        if(line < 0){line = 8;}
 | 
			
		||||
        if(line > 8){line = 0;}
 | 
			
		||||
        speed(width, height, &start_time, used);
 | 
			
		||||
    }
 | 
			
		||||
    // zürück zum alten terminal (nur linux)
 | 
			
		||||
 | 
			
		||||
    // zurück zum alten terminal (nur linux)
 | 
			
		||||
    #ifdef __linux__
 | 
			
		||||
        system("tput rmcup");
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										291
									
								
								src/pipes_test.c
									
									
									
									
									
								
							
							
						
						
									
										291
									
								
								src/pipes_test.c
									
									
									
									
									
								
							@ -1,291 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
 | 
			
		||||
#define DEBUGGER_PIPES_TO_NUMBERS 0
 | 
			
		||||
#define DEBUGGER_RANDOM 0
 | 
			
		||||
 | 
			
		||||
#define INFILL_PLAIN_PAPER 0
 | 
			
		||||
#define INFILL_X_PIPE 1
 | 
			
		||||
#define INFILL_Y_PIPE 2
 | 
			
		||||
#define FILLER "░"                      // ░
 | 
			
		||||
 | 
			
		||||
#define GRID_GROESSE_X 200              // x:y -> 2:1 for a square looking grid
 | 
			
		||||
#define GRID_GROESSE_Y 60
 | 
			
		||||
#define MIN_LAENGE_PIPE 6
 | 
			
		||||
#define MAX_LAENGE_PIPE 6
 | 
			
		||||
#define SLEEP_TIMER 10000              // in nano seconds
 | 
			
		||||
#define COLOR_CHANGING_PROBABILITY 10   // format: "(1 : your_number)", for every direction change
 | 
			
		||||
 | 
			
		||||
#define RESET_COLOR "\033[0m"
 | 
			
		||||
#define RED "\033[31m"
 | 
			
		||||
#define GREEN "\033[32m"
 | 
			
		||||
#define YELLOW "\033[33m"
 | 
			
		||||
#define BLUE "\033[34m"
 | 
			
		||||
#define MAGENTA "\033[35m"
 | 
			
		||||
#define CYAN "\033[36m"
 | 
			
		||||
#define WHITE "\033[37m"
 | 
			
		||||
 | 
			
		||||
const char* color;
 | 
			
		||||
const char *colors[] = {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
 | 
			
		||||
 | 
			
		||||
void random_color() {
 | 
			
		||||
    color = colors[rand() % (sizeof(colors) / sizeof(colors[0]))];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_grid(int x, int y, char **grid) {
 | 
			
		||||
    for (int i = 0; i < y; i++) {
 | 
			
		||||
        printf("\n");
 | 
			
		||||
        for (int j = 0; j < x; j++) {
 | 
			
		||||
            /*
 | 
			
		||||
            switch (grid[i][j]) {
 | 
			
		||||
                case 0: printf(" "); break;
 | 
			
		||||
                case 1: printf("━"); break;
 | 
			
		||||
                case 2: printf("┃"); break;
 | 
			
		||||
            }
 | 
			
		||||
            */
 | 
			
		||||
            if (!DEBUGGER_PIPES_TO_NUMBERS){
 | 
			
		||||
                if(grid[i][j] == 0){
 | 
			
		||||
                    printf(FILLER);
 | 
			
		||||
                } else if(grid[i][j] != 0 && grid[i][j] != 1 && grid[i][j] != 2){
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s╋", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┓", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┗", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┏", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┛", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┣", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┫", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 2 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┳", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┻", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] == 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] != 0 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] != 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 1 && grid[i + 1][j] == 0 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] == 1 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 1 && grid[i + 1][j] == 1 && grid[i][j - 1] == 1 && grid[i][j + 1] == 1 && grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 0 && grid[i][j + 1] == 2 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 2 && grid[i][j + 1] == 0 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 2 && grid[i + 1][j] == 2 && grid[i][j - 1] == 2 && grid[i][j + 1] == 2 && grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] == 0  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] == 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] != 0 && grid[i + 1][j] == 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┻", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j] == 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┳", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i - 1][j + 1] == 0 && grid[i - 1][j] != 0 && grid[i + 1][j] != 0 && grid[i][j - 1] != 0 && grid[i][j + 1] != 0 && grid[i][j] != 0  ){
 | 
			
		||||
                    printf("%s┗", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i][j] == 2  ){
 | 
			
		||||
                    printf("%s┃", color);
 | 
			
		||||
 | 
			
		||||
                } else if(grid[i][j] == 1  ){
 | 
			
		||||
                    printf("%s━", color);
 | 
			
		||||
                } else{printf("x");}
 | 
			
		||||
                    printf(RESET_COLOR); // Setzt die Farbe zurück
 | 
			
		||||
            }else{
 | 
			
		||||
                printf("%i", grid[i][j]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void generate_pipe_x(int x, int y, char **grid, int *x_start, int *y_start, int laenge) {
 | 
			
		||||
    if(laenge < 0){
 | 
			
		||||
        for (int i = *x_start; i > *x_start + laenge; i--) {
 | 
			
		||||
            grid[*y_start][i] = INFILL_X_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            print_grid(x, y, grid);
 | 
			
		||||
            usleep(SLEEP_TIMER);
 | 
			
		||||
        }
 | 
			
		||||
    } else{
 | 
			
		||||
        for (int i = *x_start; i < *x_start + laenge; i++) {
 | 
			
		||||
            grid[*y_start][i] = INFILL_X_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            print_grid(x, y, grid);
 | 
			
		||||
            usleep(SLEEP_TIMER);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    *x_start += laenge;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void generate_pipe_y(int x, int y, char **grid, int *x_start, int *y_start, int laenge) {
 | 
			
		||||
    if(laenge < 0){
 | 
			
		||||
        for (int i = *y_start; i > *y_start + laenge/2; i--) {
 | 
			
		||||
            grid[i][*x_start] = INFILL_Y_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            print_grid(x, y, grid);
 | 
			
		||||
            usleep(SLEEP_TIMER);
 | 
			
		||||
        }
 | 
			
		||||
    } else{
 | 
			
		||||
        for (int i = *y_start; i < *y_start + laenge/2; i++) {
 | 
			
		||||
            grid[i][*x_start] = INFILL_Y_PIPE;
 | 
			
		||||
            printf("\33[H\033[J");
 | 
			
		||||
            print_grid(x, y, grid);
 | 
			
		||||
            usleep(SLEEP_TIMER);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /*
 | 
			
		||||
    for (int i = *y_start; i < *y_start + laenge/2; i++) {
 | 
			
		||||
        grid[i][*x_start] = 2;
 | 
			
		||||
        printf("\33[H\033[J");
 | 
			
		||||
        //fflush(stdout);
 | 
			
		||||
        //usleep(100000);
 | 
			
		||||
        print_grid(x, y, grid);
 | 
			
		||||
        sleep_seconds(SLEEP_TIMER);
 | 
			
		||||
    }*/
 | 
			
		||||
    
 | 
			
		||||
    *y_start += laenge/2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main_program() {
 | 
			
		||||
 | 
			
		||||
    int x_start = GRID_GROESSE_X / 2;
 | 
			
		||||
    int y_start = GRID_GROESSE_Y / 2;
 | 
			
		||||
    int laenge = 20;
 | 
			
		||||
    int max_l = MAX_LAENGE_PIPE + 1 - MIN_LAENGE_PIPE;
 | 
			
		||||
    int min_l = MIN_LAENGE_PIPE - 1;
 | 
			
		||||
    int color_c_p = COLOR_CHANGING_PROBABILITY + 1;
 | 
			
		||||
    srand(time(NULL));
 | 
			
		||||
 | 
			
		||||
    random_color();
 | 
			
		||||
 | 
			
		||||
    char **grid = malloc(GRID_GROESSE_Y * sizeof(char *));
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
        grid[i] = malloc(GRID_GROESSE_X * sizeof(char));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
        for (int j = 0; j < GRID_GROESSE_X; j++) {
 | 
			
		||||
            grid[i][j] = INFILL_PLAIN_PAPER;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    int richtungswechsler = 1;
 | 
			
		||||
    
 | 
			
		||||
    while (!DEBUGGER_RANDOM) {
 | 
			
		||||
 | 
			
		||||
        if ((rand() %color_c_p) <= 1) {
 | 
			
		||||
            random_color();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ((rand() %2)-1) {
 | 
			
		||||
            laenge = ((rand() %max_l)+min_l);
 | 
			
		||||
        } else {
 | 
			
		||||
            laenge = ((rand() %max_l)+min_l)*-1;
 | 
			
		||||
        }
 | 
			
		||||
        if (richtungswechsler == 1) {
 | 
			
		||||
            generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
            richtungswechsler *= -1;
 | 
			
		||||
        } else {
 | 
			
		||||
            generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
            richtungswechsler *= -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (DEBUGGER_RANDOM) {
 | 
			
		||||
        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -0.1);
 | 
			
		||||
        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1.05);
 | 
			
		||||
        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * -1);
 | 
			
		||||
        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.1);
 | 
			
		||||
        generate_pipe_y(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge * 0.9);
 | 
			
		||||
        generate_pipe_x(GRID_GROESSE_X, GRID_GROESSE_Y, grid, &x_start, &y_start, laenge);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < GRID_GROESSE_Y; i++) {
 | 
			
		||||
           free(grid[i]);
 | 
			
		||||
       }
 | 
			
		||||
       free(grid);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pipes() {
 | 
			
		||||
    pid_t pid;
 | 
			
		||||
    int status;
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
        pid = fork(); // Erzeuge einen neuen Prozess
 | 
			
		||||
        if (pid == 0) {
 | 
			
		||||
            // Kindprozess führt die Hauptlogik aus
 | 
			
		||||
            main_program();
 | 
			
		||||
            exit(0); // Normales Beenden, falls kein Fehler
 | 
			
		||||
        } else if (pid > 0) {
 | 
			
		||||
            // Elternprozess wartet auf das Kind
 | 
			
		||||
            wait(&status);
 | 
			
		||||
            if (WIFEXITED(status)) {
 | 
			
		||||
                break; // Beende die Schleife, falls alles ok ist
 | 
			
		||||
            } else if (WIFSIGNALED(status)) {
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            perror("Fehler bei fork()");
 | 
			
		||||
            exit(1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,7 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int pipes();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										29
									
								
								src/test_prog.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/test_prog.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Photonics helper sub programm
 | 
			
		||||
Programmvorlage für die subprogramme
 | 
			
		||||
 | 
			
		||||
Autor: Noah Balsinger, Thomas Zwicker
 | 
			
		||||
Version: 0.1
 | 
			
		||||
Datum: 04.12.2024
 | 
			
		||||
Änderungen:
 | 
			
		||||
0.1 04.12.2024 Dokument erstellt
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int test_gruppe_programmname(){
 | 
			
		||||
    // Tasschenrechner beispiel
 | 
			
		||||
    int x;
 | 
			
		||||
    int y;
 | 
			
		||||
 | 
			
		||||
    printf("Bitte Zahl 1 eingeben: ");
 | 
			
		||||
    scanf("%i", &x);
 | 
			
		||||
    // printf("Bitte Zahl 2 eingeben: ");
 | 
			
		||||
    // scanf("%i", &y);
 | 
			
		||||
 | 
			
		||||
    // printf("Die Summe von Zahl1 und Zahl2 ist: %i\n", x + y);
 | 
			
		||||
 | 
			
		||||
    return x;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								src/test_prog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/test_prog.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
 | 
			
		||||
int test_gruppe_programmname();
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user