#include <stdio.h>
#include <string.h>
int main(void) {
char strc[12][3] = {"黒", "茶", "赤", "橙", "黄", "緑", "青", "紫", "灰", "白", "金", "銀"};
char instr[10][3]; // 最大10色の入力用
int bai[12] = {0, 1, 2, 3, 4, 5, 6, 7, 0, -3, -1, -2};
double pre[12] = {0, 1, 2, 0.05, 0, 0.5, 0.25, 0.1, 0, 0, 5, 10};
int i, j, k, b, p;
int C[5]; // 抵抗のカラーコードの数値を格納する配列
for (i = 0; i <= 2; i++) {
for (j = 0; j <= 11; j++) {
for (k = 0; k <= 2; k++) {
if (!(instr[i][k] == strc[j][k])) {
goto A1;
}
}
C[i] = j;
A1:;
}
}
i = 3;
for (j = 0; j <= 11; j++) {
for (k = 0; k <= 2; k++) {
if (!(instr[i][k] == strc[j][k])) {
goto A2;
}
}
b = j;
A2:;
}
i = 4;
for (j = 0; j <= 11; j++) {
for (k = 0; k <= 2; k++) {
if (!(instr[i][k] == strc[j][k])) {
goto A3;
}
}
p = j;
A3:;
}
printf("%d %d %d %d\n", C
[0], C
[1], b
, p
); printf("抵抗値=%d×10^(%d)[Ω] 精度=%.2f[%%]\n", 100 * C
[0] + 10 * C
[1] + C
[2], bai
[b
], pre
[p
]);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KIAppbnQgbWFpbih2b2lkKSB7CiAgICBjaGFyIHN0cmNbMTJdWzNdID0geyLpu5IiLCAi6Iy2IiwgIui1pCIsICLmqZkiLCAi6buEIiwgIue3kSIsICLpnZIiLCAi57SrIiwgIueBsCIsICLnmb0iLCAi6YeRIiwgIumKgCJ9OwogICAgY2hhciBpbnN0clsxMF1bM107ICAvLyDmnIDlpKcxMOiJsuOBruWFpeWKm+eUqAogICAgaW50IGJhaVsxMl0gPSB7MCwgMSwgMiwgMywgNCwgNSwgNiwgNywgMCwgLTMsIC0xLCAtMn07CiAgICBkb3VibGUgcHJlWzEyXSA9IHswLCAxLCAyLCAwLjA1LCAwLCAwLjUsIDAuMjUsIDAuMSwgMCwgMCwgNSwgMTB9OyAKICAgIGludCBpLCBqLCBrLCBiLCBwOwogICAgaW50IENbNV07ICAvLyDmirXmipfjga7jgqvjg6njg7zjgrPjg7zjg4njga7mlbDlgKTjgpLmoLzntI3jgZnjgovphY3liJcKIAogICAgc3RyY3B5KGluc3RyWzBdLCAi57SrIik7ICAKICAgIHN0cmNweShpbnN0clsxXSwgIum7hCIpOyAgCiAgICBzdHJjcHkoaW5zdHJbMl0sICLmqZkiKTsgIAogICAgc3RyY3B5KGluc3RyWzNdLCAi6LWkIik7ICAKICAgIHN0cmNweShpbnN0cls0XSwgIuiMtiIpOyAgCiAKICAgIGZvciAoaSA9IDA7IGkgPD0gMjsgaSsrKSB7CiAgICAgICAgZm9yIChqID0gMDsgaiA8PSAxMTsgaisrKSB7CiAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPD0gMjsgaysrKSB7CiAgICAgICAgICAgICAgICBpZiAoIShpbnN0cltpXVtrXSA9PSBzdHJjW2pdW2tdKSkgewogICAgICAgICAgICAgICAgICAgIGdvdG8gQTE7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgQ1tpXSA9IGo7CiAgICAgICAgICAgIEExOjsKICAgICAgICB9CiAgICB9CiAKICAgIGkgPSAzOwogICAgZm9yIChqID0gMDsgaiA8PSAxMTsgaisrKSB7CiAgICAgICAgZm9yIChrID0gMDsgayA8PSAyOyBrKyspIHsKICAgICAgICAgICAgaWYgKCEoaW5zdHJbaV1ba10gPT0gc3RyY1tqXVtrXSkpIHsKICAgICAgICAgICAgICAgIGdvdG8gQTI7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYiA9IGo7CiAgICAgICAgQTI6OwogICAgfQogCiAgICBpID0gNDsKICAgIGZvciAoaiA9IDA7IGogPD0gMTE7IGorKykgewogICAgICAgIGZvciAoayA9IDA7IGsgPD0gMjsgaysrKSB7CiAgICAgICAgICAgIGlmICghKGluc3RyW2ldW2tdID09IHN0cmNbal1ba10pKSB7CiAgICAgICAgICAgICAgICBnb3RvIEEzOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHAgPSBqOwogICAgICAgIEEzOjsKICAgIH0KIAogICAgcHJpbnRmKCIlZCAlZCAlZCAlZFxuIiwgQ1swXSwgQ1sxXSwgYiwgcCk7CiAgICBwcmludGYoIuaKteaKl+WApD0lZMOXMTBeKCVkKVvOqV0gIOeyvuW6pj0lLjJmWyUlXVxuIiwgMTAwICogQ1swXSArIDEwICogQ1sxXSArIENbMl0sIGJhaVtiXSwgcHJlW3BdKTsKIAogICAgcmV0dXJuIDA7Cn0K