두 수의 나눗셈
나의 풀이
using System;
public class Solution {
public int solution(int num1, int num2) {
double solution = ((double)num1/num2)*1000;
return (int)solution;
}
}
다른 사람 풀이
using System;
public class Solution {
public int solution(int num1, int num2) {
int answer = 0;
answer = num1 * 1000 / num2;
return answer;
}
}
각도기
나의 풀이
using System;
public class Solution {
public int solution(int angle) {
int answer = 0;
if(angle < 90)
{
answer = 1;
}
else if(angle == 90)
{
answer = 2;
}
else if(angle > 90 && angle < 180)
{
answer = 3;
}
else
{
answer = 4;
}
return answer;
}
}
다른 사람풀이
using System;
public class Solution {
public int solution(int angle) {
int answer = angle < 90 ? 1 : angle == 90 ? 2 : angle < 180 ? 3 : 4;
return answer;
}
}
짝수의 합
나의 풀이
using System;
public class Solution {
public int solution(int n) {
int answer = 0;
for(int i = 2; i <= n; i++)
{
if(i % 2 == 0)
{
answer += i;
}
}
return answer;
}
}
다른 사람 풀이
using System;
public class Solution {
public int solution(int n) {
return n/2*(n/2+1);
}
}
'TIL' 카테고리의 다른 글
12.04 (TIL-코딩문제) (1) | 2023.12.04 |
---|---|
12.01 (TIL-Unity) (0) | 2023.12.01 |
11.29 (TIL-Unity) (0) | 2023.11.29 |
11.28 (TIL-코딩문제) (0) | 2023.11.28 |
11.27 (TIL-Unity) (0) | 2023.11.27 |