-
-
Save Gofilord/15fffe1a0f6c9b694d24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(string[] args) | |
{ | |
// let's say there are 10 boys, 11 girls and each girl gets to choose 5 | |
const int BOY_AMOUNT = 10; | |
const int GIRL_AMOUNT = 11; | |
const int CHOICE_AMOUNT = 5; | |
// indexes are serial numbers and the values are their scores | |
int[] boys = new int[BOY_AMOUNT]; | |
// init boys | |
for (int i = 0; i < boys.Length(); i++) | |
boys[i] = 0; | |
// looping through all the girls | |
// to get their score on each of the ten boys | |
for (int i = 0; i < GIRL_AMOUNT; i++) | |
{ | |
int serial, score; | |
// looping through all the boys for this girl | |
for (int j = 0; j < CHOICE_AMOUNT; j++) | |
{ | |
Console.WriteLine(i + ") enter boy's serial number: "); | |
serial = int.parse(Console.ReadLine()); | |
Console.WriteLine(i + ") enter boy's score: "); | |
score = int.parse(Console.ReadLine()); | |
boys[serial] = score; | |
} | |
} | |
/// finding the prom king and who didn't get invited at all | |
int king = 1; // that's the lowest score | |
int looserAmount = 0; // for the amount of boys no one chose | |
for (int i = 0; i < boys.Length; i++) | |
{ | |
// finding the max score ("king") | |
if (boys[i] > king) | |
king = boys[i]; | |
// find how much boys have a score of 0 | |
// which means they got no score at all | |
if (boys[i] == 0) | |
looserAmount++; | |
} | |
// printing the results | |
Console.WriteLine("Prom king: " + king); | |
Console.WriteLine("Amount of people that no one asked: " + looserAmount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment