VioletaBabel

1076번: 저항 본문

백준/백준-C++
1076번: 저항
Beabletoet 2017. 6. 5. 23:27

#include<iostream>

#include<utility>

#include<string>

#include<cmath>

using namespace std;

int main()

{

pair<string, long long> ohm[10];

long long num;

string com;

for (int i = 0; i < 10; ++i)

ohm[i].second = i;

ohm[0].first = "black";

ohm[1].first = "brown";

ohm[2].first = "red";

ohm[3].first = "orange";

ohm[4].first = "yellow";

ohm[5].first = "green";

ohm[6].first = "blue";

ohm[7].first = "violet";

ohm[8].first = "grey";

ohm[9].first = "white";

cin >> com;

for (int i = 0; i < 10; ++i)

if (ohm[i].first == com)

{

num = ohm[i].second * 10;

break;

}

cin >> com;

for (int i = 0; i < 10; ++i)

if (ohm[i].first == com)

{

num += ohm[i].second;

break;

}

cin >> com;

for (int i = 0; i < 10; ++i)

if (ohm[i].first == com)

{

num *= (pow(10, ohm[i].second));

break;

}

cout << num;

}

'백준 > 백준-C++' 카테고리의 다른 글

1927번: 최소 힙  (0) 2017.06.05
1764번: 듣보잡  (0) 2017.06.05
10816번: 숫자 카드 2 (실패)  (0) 2017.06.05
10815번: 숫자 카드  (0) 2017.06.05
10867번: 중복 빼고 정렬하기  (0) 2017.06.05
Comments