컴퓨터공학 💻 도서관📚

백준 1076번 본문

💣😝알고리즘 문제(CAM)/C언어

백준 1076번

들판속초록풀 2022. 1. 19. 12:04

백준 1076번 문제

#include <stdio.h>
#include <string.h>
#pragma warning(disable:4996)  

struct resist_num {
	char color_name[7];
	long long color_price;
	long long multiplying_number;
};
int main() {
	struct resist_num resist[10] = { {"black", 0, 1},{"brown", 1, 10},{"red", 2, 100},
		{"orange", 3, 1000},{"yellow", 4, 10000},{"green", 5, 100000},{"blue",6, 1000000},
		{"violet", 7, 10000000},{"grey", 8, 100000000},{"white", 9, 1000000000} };

	char word_one[7] = {0};
	char word_two[7]= {0};
	char word_three[7]= {0};
	long long n1=0, n2=0, n3=0 ;
	long long answer=0;
	gets(word_one);
	gets(word_two);
	gets(word_three);

	for (int i = 0; i < 10; i++)
	{
		if (strcmp(word_one, (resist + i)->color_name) == 0)
		{
			n1 = (resist + i)->color_price;
		}
		if (strcmp(word_two, (resist + i)->color_name) == 0)
		{
			n2 = (resist + i)->color_price;
		}
		if (strcmp(word_three, (resist + i)->color_name) == 0)
		{
			n3 = (resist + i)->multiplying_number;
		}
	}
	answer = (n1 * 10 + n2) * n3;
	printf("%lld", answer);

	return 0;
}
Comments