Untitled
unknown
plain_text
10 months ago
1.9 kB
13
Indexable
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Witaj w Quiziz!\n Interaktywnym Quizie wiedzy!");
Console.WriteLine("Odpowiedz na odpowiedź wpisując numer odpowiedzi!");
Console.WriteLine("1 poprawna odpowiedź to +1 punkt!");
string[] questions = {
"Czym jest Słońce?",
"Którą planetą od Słońca jest Ziemia?",
"Ile jest planet w układzie słonecznym?",
};
string[,] answers = {
{"1. Planetą", "\n2. Meteorytem", "\n3. Gwiazdą"},
{"1. 1", "\n2. 3", "\n3. 9"},
{"1. 8", "\n2. 9", "\n3. 4"},
};
int[] correct_answers = {3, 2, 1};
int score = 0;
for(int i = 0; i < questions.Length; i++)
{
Console.WriteLine($"\nPytanie {i + 1}: {questions[i]}");
for(int j = 0; j <3; j++)
{
Console.WriteLine(answers[i, j]);
}
Console.WriteLine("Twoja odpowiedź: ");
int user_answer;
while(!int.TryParse(Console.ReadLine(), out user_answer) || user_answer < 1 || user_answer > 3)
{
Console.WriteLine("ERROR: niepoprawny \nnumer odpowiedzi \n(poprawne odp. 1-3)");
}
if(user_answer == correct_answers[i])
{
Console.WriteLine("Poprawna odpwoiedź! +1 pkt.!");
score++;
}
else
{
if(i == 2 && user_answer == 2)
{
Console.WriteLine("Liczysz Plutona? +0pkt.");
}
else
{
Console.WriteLine("Njope +0pkt.!");
}
}
Console.WriteLine(score);
}
}
}Editor is loading...
Leave a Comment