Compare commits
2 Commits
aace8845a8
...
122dcd5a02
Author | SHA1 | Date | |
---|---|---|---|
122dcd5a02 | |||
aafbd8a4e0 |
58
farben.c
Normal file
58
farben.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SIZE 3
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
const char *farben[] = { "Gruen", "Rot", "Violett" };
|
||||||
|
|
||||||
|
|
||||||
|
const char *mischungen[SIZE][SIZE] = {
|
||||||
|
{"Gruen", "Gelb", "Blau"},
|
||||||
|
{"Gelb", "Rot", "Purpur"},
|
||||||
|
{"Blau", "Purpur", "Violett"}
|
||||||
|
};
|
||||||
|
|
||||||
|
char eingabe1[20], eingabe2[20];
|
||||||
|
int index1 = -1, index2 = -1;
|
||||||
|
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
printf("Erste Grundfarbe (Gruen, Rot, Violett): ");
|
||||||
|
scanf("%s", eingabe1);
|
||||||
|
|
||||||
|
for (int i = 0; i < SIZE; i++) {
|
||||||
|
if (strcasecmp(eingabe1, farben[i]) == 0) {
|
||||||
|
index1 = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index1 != -1) break;
|
||||||
|
else printf("... unbekannte Grundfarbe '%s'. Bitte erneut eingeben.\n", eingabe1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
printf("Zweite Grundfarbe (Gruen, Rot, Violett): ");
|
||||||
|
scanf("%s", eingabe2);
|
||||||
|
|
||||||
|
for (int i = 0; i < SIZE; i++) {
|
||||||
|
if (strcasecmp(eingabe2, farben[i]) == 0) {
|
||||||
|
index2 = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index2 != -1) break;
|
||||||
|
else printf("... unbekannte Grundfarbe '%s'. Bitte erneut eingeben.\n", eingabe2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *ergebnis = mischungen[index1][index2];
|
||||||
|
printf("Die Mischung aus %s und %s ergibt: %s\n", farben[index1], farben[index2], ergebnis);
|
||||||
|
|
||||||
|
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