Merge remote-tracking branch 'origin/main'
# Conflicts: # farben.c
This commit is contained in:
commit
5024214330
8
farben.c
8
farben.c
@ -1,14 +1,11 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define SIZE 3
|
#define SIZE 3
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const char *farben[] = { "Grün", "Rot", "Violett" };
|
|
||||||
|
|
||||||
const char *mischungen[SIZE][SIZE] = {
|
const char *mischungen[SIZE][SIZE] = {
|
||||||
{"Grün", "Gelb", "Blau"},
|
|
||||||
{"Gelb", "Rot", "Purpur"},
|
{"Gelb", "Rot", "Purpur"},
|
||||||
{"Blau", "Purpur", "Violett"}
|
{"Blau", "Purpur", "Violett"}
|
||||||
};
|
};
|
||||||
@ -17,7 +14,6 @@ int main() {
|
|||||||
int index1 = -1, index2 = -1;
|
int index1 = -1, index2 = -1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("Erste Grundfarbe (Grün, Rot, Violett): ");
|
|
||||||
scanf("%s", eingabe1);
|
scanf("%s", eingabe1);
|
||||||
|
|
||||||
for (int i = 0; i < SIZE; i++) {
|
for (int i = 0; i < SIZE; i++) {
|
||||||
@ -32,7 +28,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("Zweite Grundfarbe (Grün, Rot, Violett): ");
|
|
||||||
scanf("%s", eingabe2);
|
scanf("%s", eingabe2);
|
||||||
|
|
||||||
for (int i = 0; i < SIZE; i++) {
|
for (int i = 0; i < SIZE; i++) {
|
||||||
@ -51,6 +46,3 @@ int main() {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Created by Lennart Pecher on 30.04.25.
|
|
||||||
//
|
|
||||||
|
|||||||
77
jahrtag.c
Normal file
77
jahrtag.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void textAusgabe() {
|
||||||
|
printf("0 Ende\n"
|
||||||
|
"1 Tagesnummer zu einem Datum bestimmen\n"
|
||||||
|
"2 Datum zu einer Tagesnummer bestimmen\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void eingabeDatum(int *tag, int *monat, int *jahr) {
|
||||||
|
printf("Gib dein Datum (tt.mm.jjjj) ein: ");
|
||||||
|
scanf("%d.%d.%d", tag, monat, jahr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void eingabeTag(int *tag, int *jahr) {
|
||||||
|
printf("Gib Tagesnummer und Jahr (nr,jahr) ein: ");
|
||||||
|
scanf("%d,%d", tag, jahr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int eingabeWahl() {
|
||||||
|
int input;
|
||||||
|
printf("Deine Wahl: ");
|
||||||
|
scanf("%d", &input);
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
int istSchaltjahr(int jahr) {
|
||||||
|
return (jahr % 4 == 0 && (jahr % 100 != 0 || jahr % 400 == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int input, tag, monat, jahr, TagImJahr,schalt;
|
||||||
|
|
||||||
|
int monat_tage[2][13] = {
|
||||||
|
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||||
|
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
|
||||||
|
};
|
||||||
|
input = 1;
|
||||||
|
|
||||||
|
do{
|
||||||
|
textAusgabe();
|
||||||
|
input = eingabeWahl();
|
||||||
|
|
||||||
|
switch(input) {
|
||||||
|
case 0:
|
||||||
|
printf("Programm beendet.\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
eingabeDatum(&tag, &monat, &jahr);
|
||||||
|
schalt = istSchaltjahr(jahr);
|
||||||
|
TagImJahr = 0;
|
||||||
|
|
||||||
|
for(int i = 1;i<monat;i++) {
|
||||||
|
TagImJahr += monat_tage[schalt] [i];
|
||||||
|
}
|
||||||
|
TagImJahr += tag;
|
||||||
|
|
||||||
|
printf("%d.%d.%d = %d. Tag im Jahr\n", tag, monat, jahr, TagImJahr);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
int i = 1;
|
||||||
|
eingabeTag(&TagImJahr, &jahr);
|
||||||
|
schalt = istSchaltjahr(jahr);
|
||||||
|
tag = TagImJahr;
|
||||||
|
|
||||||
|
while (tag > monat_tage[schalt][i]) {
|
||||||
|
tag -= monat_tage[schalt][i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
monat = i;
|
||||||
|
printf(".... %d. Tag im Jahr = %d.%d.%d\n", TagImJahr, tag, monat, jahr);
|
||||||
|
|
||||||
|
}
|
||||||
|
} while (input != 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
62
laugsaeu.c
Normal file
62
laugsaeu.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NATRONLAUGE,
|
||||||
|
KALILAUGE,
|
||||||
|
KALKWASSER,
|
||||||
|
ANZAHL_LAUGEN
|
||||||
|
} Lauge;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SALZSAEURE,
|
||||||
|
SCHWEFELSAEURE,
|
||||||
|
SALPETERSAEURE,
|
||||||
|
KOHLENSAEURE,
|
||||||
|
ANZAHL_SAEUREN
|
||||||
|
} Saeure;
|
||||||
|
|
||||||
|
|
||||||
|
const char* mischtabelle[ANZAHL_LAUGEN][ANZAHL_SAEUREN] = {
|
||||||
|
{"Natriumchlorid", "Natriumsulfat", "Natriumnitrat", "Natriumcarbonat"},
|
||||||
|
{"Kaliumchlorid", "Kaliumsulfat", "Kaliumnitrat", "Kaliumcarbonat"},
|
||||||
|
{"Calciumchlorid", "Calciumsulfat", "Calciumnitrat", "Calciumcarbonat"}
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* laugen_namen[ANZAHL_LAUGEN] = {
|
||||||
|
"Natronlauge",
|
||||||
|
"Kalilauge",
|
||||||
|
"Kalkwasser"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* saeure_namen[ANZAHL_SAEUREN] = {
|
||||||
|
"Salzsäure",
|
||||||
|
"Schwefelsäure",
|
||||||
|
"Salpetersäure",
|
||||||
|
"Kohlensäure"
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf(" ||");
|
||||||
|
for (int s = 0; s < ANZAHL_SAEUREN; s++) {
|
||||||
|
printf(" %-14s|", saeure_namen[s]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
printf("-----------++");
|
||||||
|
for (int s = 0; s < ANZAHL_SAEUREN; s++) {
|
||||||
|
printf("---------------|");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
|
||||||
|
for (int l = 0; l < ANZAHL_LAUGEN; l++) {
|
||||||
|
printf("%-11s||", laugen_namen[l]);
|
||||||
|
for (int s = 0; s < ANZAHL_SAEUREN; s++) {
|
||||||
|
printf(" %-14s|", mischtabelle[l][s]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user