Program: 23.1.c
This commit is contained in:
parent
4ba80e5c45
commit
6c00c48273
38
25.6.3.c
Normal file
38
25.6.3.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int finde_zahlwort(char *wort) {
|
||||
if (strcasestr(wort, "eins")) return 1;
|
||||
if (strcasestr(wort, "zwei")) return 2;
|
||||
if (strcasestr(wort, "drei")) return 3;
|
||||
if (strcasestr(wort, "vier")) return 4;
|
||||
if (strcasestr(wort, "fünf")) return 5;
|
||||
if (strcasestr(wort, "sechs")) return 6;
|
||||
if (strcasestr(wort, "sieben")) return 7;
|
||||
if (strcasestr(wort, "acht")) return 8;
|
||||
if (strcasestr(wort, "neun")) return 9;
|
||||
if (strcasestr(wort, "zehn")) return 10;
|
||||
if (strcasestr(wort, "elf")) return 11;
|
||||
if (strcasestr(wort, "zwölf")) return 12;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char *worte[] = {
|
||||
"Endreim", "Kurzweil", "Nachtfalter", "Wohnviertel", "Neunauge",
|
||||
"Weinstein", "Erdreich", "Achtung", "Segelflieger", "Pfalzwein",
|
||||
"Radreifen", "Gehhelfer", "Leinsamen"
|
||||
};
|
||||
int summe = 0;
|
||||
|
||||
for (int i = 0; i < sizeof(worte)/sizeof(worte[0]); i++) {
|
||||
int wert = finde_zahlwort(worte[i]);
|
||||
if (wert > 0)
|
||||
printf("%s: ... %d\n", worte[i], wert);
|
||||
summe += wert;
|
||||
}
|
||||
|
||||
printf("------------------------------\n");
|
||||
printf("Summe: %d\n", summe);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user