컴퓨터공학 💻 도서관📚
백준 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;
}
'💣😝알고리즘 문제(CAM) > C언어' 카테고리의 다른 글
백준 1436번 영화감독 숌 (복습) --> c언어 버전 풀이 아이디어 (0) | 2024.08.25 |
---|
Comments