Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions 001-평균 구하기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
double solution(int arr[], size_t arr_len) {
int sum = 0;
for (int i = 0; i < arr_len; i++) {
sum += arr[i];
}

double answer = (double) sum / arr_len;

return answer;
}
10 changes: 10 additions & 0 deletions 002-짝수와홀수.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public String solution(int num) {

if (num % 2 == 0) {
return ("Even");
} else {
return("Odd");
}
}
}
14 changes: 14 additions & 0 deletions 003-자릿수 더하기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.*;

public class Solution {
public int solution(int n) {
int answer = 0;

String s = Integer.toString(n);

for(int i=0; i < s.length(); i++){
answer += Integer.parseInt(s.substring(i, i+1));
}
Comment on lines +9 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

향상된for문 공부하셔서 이 방법으로도 풀어보시면 좋을거같아요

return answer;
}
}