백준/백준-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;

}