From 00616750fdde5026219b729676534438e0298328 Mon Sep 17 00:00:00 2001 From: Florian Baeseler Date: Mon, 5 Feb 2024 20:56:23 +0100 Subject: [PATCH] =?UTF-8?q?zwei=20z=C3=A4hler-pointer=20zur=20Funktion=20a?= =?UTF-8?q?ctivePlaying=20hinzugef=C3=BCgt=20f=C3=BCr=20sp=C3=A4ter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/test/results/test_casualQuiz.pass | 2 +- build/test/results/test_quizduell.pass | 2 +- build/test/results/test_timequiz.pass | 2 +- build/test/results/test_wwm.pass | 2 +- src/casualQuiz.c | 20 ++++++++++++++------ src/casualQuiz.h | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index 1fa43bf..43c95fa 100644 --- a/build/test/results/test_casualQuiz.pass +++ b/build/test/results/test_casualQuiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.013265200017485768 +:time: 0.027896299987332895 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index f075711..4fbcee0 100644 --- a/build/test/results/test_quizduell.pass +++ b/build/test/results/test_quizduell.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.013494899991201237 +:time: 0.028896299976622686 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index f819020..4bfaa81 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.012791300017852336 +:time: 0.029049100005067885 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index 8adc593..2c5990d 100644 --- a/build/test/results/test_wwm.pass +++ b/build/test/results/test_wwm.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.013431600003968924 +:time: 0.029695000004721805 diff --git a/src/casualQuiz.c b/src/casualQuiz.c index a8af63a..20933cc 100644 --- a/src/casualQuiz.c +++ b/src/casualQuiz.c @@ -19,11 +19,19 @@ void casualQuiz() { int easy_richtigeAntworten[] = { 3,4}; // int, um die jeweils richtige antwort zu zeigen int length_frag_array = sizeof(easy_richtigeAntworten)/sizeof(int); - activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array); - return; + int correct = 0; + int answered = 0; + int *correctP = &correct; + int *answeredP = &answered; + + activePlaying(easy_fragen, *easy_antworten, easy_richtigeAntworten, length_frag_array, answeredP, correctP); + printf("%d", answered); + return; } -void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size ){ +void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size, int *answeredP, int *correctP ){ int eingabe; + int plus = *answeredP +1; + *answeredP = plus; for (int i = 0; i < size; i++){ eingabe = 5; FzeigeFragen(fragen, i); @@ -33,19 +41,19 @@ void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], in switch(eingabe){ case 1:{ printf("Case 1\n"); - if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n"); + if (richtige_antwort[i] == 1) printf("Right Answer, well done.\n"); else printf("Wrong answer."); break; } case 2:{ printf("Case 2\n"); - if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n"); + if (richtige_antwort[i] == 2) printf("Right Answer, well done.\n"); else printf("Wrong answer."); break; } case 3:{ printf("Case 3\n"); - if (richtige_antwort[i] == 4) printf("Right Answer, well done.\n"); + if (richtige_antwort[i] == 3) printf("Right Answer, well done.\n"); else printf("Wrong answer."); break; } diff --git a/src/casualQuiz.h b/src/casualQuiz.h index 90f5947..ae18d0f 100644 --- a/src/casualQuiz.h +++ b/src/casualQuiz.h @@ -2,7 +2,7 @@ #define CASUALQUIZ_H void casualQuiz(); -void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size); +void activePlaying(char *fragen[], char *antworten[], int richtige_antwort[], int size, int *answeredP, int *correctP ); void FzeigeFragen(char *fragen[], int index); void FzeigeAntworten(char *antworten[], int index); int FEingabeInteger();