문제
어떤 세균은 1시간에 두배만큼 증식한다고 합니다. 처음 세균의 마리수 n과 경과한 시간 t가 매개변수로 주어질 때 t시간 후 세균의 수를 return하도록 solution 함수를 완성해주세요.
솔루션
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int n, int t) {
int answer = 0;
answer = n;
for(int i = 0; i < t; i++)
answer *= 2;
return answer;
}
https://school.programmers.co.kr/learn/courses/30/lessons/120910
'프로그래머스코딩테스트연습풀이 > C언어' 카테고리의 다른 글
[프로그래머스/C언어] n의 배수 고르기 (0) | 2023.08.03 |
---|---|
[프로그래머스/C언어] 제곱수 판별하기 (0) | 2023.08.03 |
[프로그래머스/C언어] l로 만들기 (0) | 2023.08.03 |
[프로그래머스/C언어] 조건에 맞게 수열 변환하기 3 (0) | 2023.08.03 |
[프로그래머스/C언어] 주사위 게임 1 (0) | 2023.08.03 |