Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

week3 모의고사 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
EunjiShin merged 2 commits into TecheerB:master from yjshin229:master
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions YoungjinShin/3주차/mathTest.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.util.*;


public class mathTest{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int testCase = sc.nextInt();
int[] answer = new int[testCase];
for(int i = 0; i<testCase; i++){
answer[i] = sc.nextInt();
}
sc.close();
int[] ret = solution(answer);
System.out.print("[");
for(int i = 0; i<ret.length; i++){
System.out.print(ret[i]);
}
System.out.println("]");

}

public static int[] solution(int[] answers) {
int[] student1 = {1,2,3,4,5};
int[] student2 = {2,1,2,3,2,4,2,5};
int[] student3 = {3,3,1,1,2,2,4,4,5,5};
int[] ansCount = {0,0,0};

for (int i = 0; i< answers.length; i++){
if (student1[(i % student1.length)] == answers[i]){
ansCount[0] ++;
}
if (student2[i%student2.length] == answers[i]){
ansCount[1] ++;
}
if (student3[i%student3.length] == answers[i]){
ansCount[2] ++;
}
}

List<Integer> tempanswer = new ArrayList<>();

int max = Arrays.stream(ansCount).max().getAsInt();

for (int i = 0; i < ansCount.length; i++){
if (ansCount[i] == max){
tempanswer.add(i+1);
}
}
int[] answer = tempanswer.stream().mapToInt(i -> i).toArray();

return answer;
}
}

AltStyle によって変換されたページ (->オリジナル) /