Structural-J.G

 avatar
unknown
c_cpp
3 years ago
1.0 kB
4
Indexable
#include <iostream>

#include <string>

#include <stdlib.h>

using namespace std;

const int QUSTION_COUNT = 3;
struct sQuestions {
  string data;
  string a, b, c;
  char correct;
};

sQuestions data[QUSTION_COUNT] = {
  {
    "Jaki dzwiek wydaje kot?",
    "miau",
    "hau",
    "muu",
    'a'
  },
  {
    "Najwazniejsza osoba w Polsce?",
    "premier",
    "prezes",
    "prezydent",
    'c'
  },
  {
    "Ktora godzina to polnoc?",
    "11:00",
    "12:00",
    "0:00",
    'c'
  }
};

int main() {
  int points = 0;
  for (int i = 0; i < QUSTION_COUNT; i++) {
    char answer;
    sQuestions currentQuestion = data[i];
    cout << to_string(i + 1) + ") " << currentQuestion.data << endl;
    cout << " a) " + currentQuestion.a << endl;
    cout << " b) " + currentQuestion.b << endl;
    cout << " c) " + currentQuestion.c << endl;
    cout << "Podaj odp:" << endl;
    cin >> answer;
    if (answer == currentQuestion.correct) {
      points++;
    }
  }
  cout << "Twój wynik to: " << points << endl;
  return 0;
}
Editor is loading...