Skip to content

Instantly share code, notes, and snippets.

@JorgeOlvera
Created December 2, 2013 06:23
Show Gist options
  • Save JorgeOlvera/7745865 to your computer and use it in GitHub Desktop.
Save JorgeOlvera/7745865 to your computer and use it in GitHub Desktop.
/*General Election is over, now it is time to count the votes!
//There are n (2 <= n <= 5) candidates and m (1 <= m <= 100) vote regions.
//Given the number of votes for each candidate from each region,
//determine which candidate is the winner (one with the most votes.
//The first line of input contains an integer T (1 <= T <= 100),
//the number of test cases follow. Each test case starts with two
//integers n and m denoting the number of candidate and number of region.
//The next m lines each contains n integers, V1, V2, ..., Vn (0 <= Vi <= 1000)
//the number of votes for candidate i.
//output in a line the winning candidate. You may safely assume that the winner is unique.*/
import java.io.*;
import java.util.Scanner;
public class electionsfinal2{
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
char candidate;
int regions = input.nextLine();
do {
int[] elArray = new int[regions];
char[] candidate = input.nextLine().charAt(0);
int[] regionM = input.nextLine().(nric.charAt(3), 4, 5);
int[] votes = input.nextLine();
int[] votesCandidates = votes + candidate;
}
while (regions >= 1 && regions <= 100);
if (candidate == 2 && votes > votesCandidates) {
System.out.println("Winner is" + candidate);
}
else if (candidate == 3 && votes > votesCandidates) {
System.out.println("Winner is" + candidate);
}
else if (candidate == 4 && votes > votesCandidates) {
System.out.println("Winner is" + candidate);
}
else (candidate == 5 && votes > votesCandidates) {
System.out.println("Winner is" + candidate);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment