// Thema's en teams string[] themaRondes = { "Sport", "Cultuur", "Politiek" }; int aantalTeams = 4; string[] teamNamen = new string[aantalTeams]; int[,] scores = new int[aantalTeams, themaRondes.Length]; // Namen en scores invoeren for (int i = 0; i < aantalTeams; i++) { Console.Write($"Voer de naam in van team {i + 1}: "); teamNamen[i] = Console.ReadLine(); for (int j = 0; j < themaRondes.Length; j++) { Console.Write($"{teamNamen[i]}, {themaRondes[j]} score: "); scores[i, j] = int.Parse(Console.ReadLine()); } } // Winnaars per ronde bepalen for (int j = 0; j < themaRondes.Length; j++) { int hoogsteScore = -1; string winnaar = ""; for (int i = 0; i < aantalTeams; i++) { if (scores[i, j] > hoogsteScore) { hoogsteScore = scores[i, j]; winnaar = teamNamen[i]; } } Console.WriteLine($" Winnaar van de {themaRondes[j]} ronde is: {winnaar} met {hoogsteScore} punten."); }
// Thema's en teams string[] themaRondes = { "Sport", "Cultuur", "Politiek" }; int aantalTeams = 4; string[] teamNamen = new string[aantalTeams]; int[,] scores = new int[aantalTeams, themaRondes.Length]; // Namen en scores invoeren for (int i = 0; i < aantalTeams; i++) { Console.Write($"Voer de naam in van team {i + 1}: "); teamNamen[i] = Console.ReadLine(); for (int j = 0; j < themaRondes.Length; j++) { Console.Write($"{teamNamen[i]}, {themaRondes[j]} score: "); scores[i, j] = int.Parse(Console.ReadLine()); } } // Winnaars per ronde bepalen for (int j = 0; j < themaRondes.Length; j++) { int hoogsteScore = -1; string winnaar = ""; for (int i = 0; i < aantalTeams; i++) { if (scores[i, j] > hoogsteScore) { hoogsteScore = scores[i, j]; winnaar = teamNamen[i]; } } Console.WriteLine($" Winnaar van de {themaRondes[j]} ronde is: {winnaar} met {hoogsteScore} punten."); }
That's not what happened. The .Length property was used to establish how many times the for loop needed to run, based on the length of the array that he defined. Whatever number the user input had to be checked whether it occurred in his predefined array. If it matched one of the elements, then the bool is set to true and finally an if statement printed the appropriate message based on the state of the bool.
To Get Certification, Click Here: bitly.ws/P9Up
Use coupon "TH-cam12" to get ‘’FLAT 12%’’ OFF at Checkout.
// Thema's en teams
string[] themaRondes = { "Sport", "Cultuur", "Politiek" };
int aantalTeams = 4;
string[] teamNamen = new string[aantalTeams];
int[,] scores = new int[aantalTeams, themaRondes.Length];
// Namen en scores invoeren
for (int i = 0; i < aantalTeams; i++)
{
Console.Write($"Voer de naam in van team {i + 1}: ");
teamNamen[i] = Console.ReadLine();
for (int j = 0; j < themaRondes.Length; j++)
{
Console.Write($"{teamNamen[i]}, {themaRondes[j]} score: ");
scores[i, j] = int.Parse(Console.ReadLine());
}
}
// Winnaars per ronde bepalen
for (int j = 0; j < themaRondes.Length; j++)
{
int hoogsteScore = -1;
string winnaar = "";
for (int i = 0; i < aantalTeams; i++)
{
if (scores[i, j] > hoogsteScore)
{
hoogsteScore = scores[i, j];
winnaar = teamNamen[i];
}
}
Console.WriteLine($"
Winnaar van de {themaRondes[j]} ronde is: {winnaar} met {hoogsteScore} punten.");
}
Thank you, you're amazing explaining, greetings from Argentina
Array are part of "Reference Type". Which store the reference on----stack
values in ---heaps
**Array has size which is static.
Thanks so much for this video, very clear and helpful, this saved my homework assignment
you lazy😫
Really nice and informative video.
Thank you so much to clear the Concept of array with examples
// Thema's en teams
string[] themaRondes = { "Sport", "Cultuur", "Politiek" };
int aantalTeams = 4;
string[] teamNamen = new string[aantalTeams];
int[,] scores = new int[aantalTeams, themaRondes.Length];
// Namen en scores invoeren
for (int i = 0; i < aantalTeams; i++)
{
Console.Write($"Voer de naam in van team {i + 1}: ");
teamNamen[i] = Console.ReadLine();
for (int j = 0; j < themaRondes.Length; j++)
{
Console.Write($"{teamNamen[i]}, {themaRondes[j]} score: ");
scores[i, j] = int.Parse(Console.ReadLine());
}
}
// Winnaars per ronde bepalen
for (int j = 0; j < themaRondes.Length; j++)
{
int hoogsteScore = -1;
string winnaar = "";
for (int i = 0; i < aantalTeams; i++)
{
if (scores[i, j] > hoogsteScore)
{
hoogsteScore = scores[i, j];
winnaar = teamNamen[i];
}
}
Console.WriteLine($"
Winnaar van de {themaRondes[j]} ronde is: {winnaar} met {hoogsteScore} punten.");
}
Thanks, man, it's very helpful
please give runtime examples as well
Thank you 😊
sir why are we using .length when we store the value from user
That's not what happened. The .Length property was used to establish how many times the for loop needed to run, based on the length of the array that he defined. Whatever number the user input had to be checked whether it occurred in his predefined array. If it matched one of the elements, then the bool is set to true and finally an if statement printed the appropriate message based on the state of the bool.
I love this
Thanks a lot
jagged Array is xossssssssssssssss
how we use INPTR in cPP ???
i want to store array value from user , how can i store?
th-cam.com/play/PLdOT12odxrUoNQeRyIZtV9gEaKmK2YRD4.html
I know about it
Good video.
But not perfectly explaining!
He didn't know how to explain it properly
Did you see the pictorial representation of the array?