Compare commits
No commits in common. "122dcd5a02d93206e7d3ac12c6849ef79082e8e3" and "aace8845a8d3fdcc5bd5a8027431366e72693764" have entirely different histories.
122dcd5a02
...
aace8845a8
58
farben.c
58
farben.c
@ -1,58 +0,0 @@
|
|||||||
#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
62
laugsaeu.c
@ -1,62 +0,0 @@
|
|||||||
#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