Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

hwooo

BOJ (C/C++) 1076번: 저항 본문

Study/Algorithm

BOJ (C/C++) 1076번: 저항

hwooo 2022. 11. 6. 23:23

코드

#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
	char S[10][7] = { "black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white" };
	char s1[7], s2[7], s3[7];
	long int R = 0;
	scanf("%s %s %s", s1, s2, s3);
	for (int i = 0; i < 10; i++) {
		if (strcmp(s1, S[i]) == 0) R += i * 10;
		if (strcmp(s2, S[i]) == 0) R += i;
	}
	for (int i = 0; i < 10; i++) {
		if (strcmp(s3, S[i]) == 0) R *= pow(10, i);
	}
        // 출력값 범위 주의
	printf("%ld", R);
	return 0;
}