728x90 c code3 [C Examples] Stack을 활용해서 Stack 값 바꿔보기, Dynamic stack Stack을 활용해서 Stack 값 바꿔보기, Dynamic stack 포스트 난이도: HOO_Junior # Example Code 1 이번 포스트에서는 C언어의 Stack (스택) 값을 바꿔보는 예제코드를 통해 스택에 대해서 보다 더 익숙해질 수 있다. 특히 이번 예제코드에서는 동적 배열 또는 동적 스택이라고 불리는 Dynamic stack에 대해서 살펴볼 수 있다. 아래의 예제코드 1을 보면 Lottery 숫자가 스택으로 주어져있는 상황에서 사용자가 임의의 7자리 숫자를 입력하고 난 뒤에 중간 스택에 새로운 값이 추가되는 걸 확인할 수 있다. 이때 예제코드 1에서는 중간 배열의 스택이 지속적으로 추가가 되어 처음 스택보다 스택의 값이 증가하는 걸 알 수 있다. 반면에 예제코드 2에서는 중간에 새롭게.. 2023. 11. 9. [C Examples] 시간대별 통화요금 계산기 예제코드: if, else, char 시간대별 통화요금 계산기 예제코드: if, else, char 포스트 난이도: HOO_Junior # Example Codes #include #include int main() { int min, dayOrNight; float rCharge, pCharge; char serviceCode; printf("The rates are computed as follows: Regular service: $10.00 plus first 50 minutes are free.\n"); printf("Charges for over 50 minutes are $0.20 per minute, Premium service: $25.00 plus. \n"); printf("Enter your service code:");.. 2023. 2. 20. [C Examples] 세금 계산기 예제코드: if, else if 세금 계산기 예제코드: if, else if 포스트 난이도: HOO_Intern # Example Codes #include #include int main() { float salary,tax; tax = 0; printf("Income: $"); scanf("%f",&salary); if (salary < 1000) { tax = 0.01 * salary; } else if (salary < 2000) { salary=salary-1000; tax = 0.01 * salary; tax = tax + 10; } else if (salary 2023. 2. 19. 이전 1 다음 728x90