fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. char strc[12][3] = {"黒", "茶", "赤", "橙", "黄", "緑", "青", "紫", "灰", "白", "金", "銀"};
  5. char instr[10][3];
  6. int bai[12] = {0, 1, 2, 3, 4, 5, 6, 7, 0, -3, -1, -2};
  7. double pre[12] = {0, 1, 2, 0.05, 0, 0.5, 0.25, 0.1, 0, 0, 5, 10};
  8. int i, j, k, b, p;
  9. int C[4];
  10.  
  11. strcpy(instr[0], "赤");
  12. strcpy(instr[1], "茶");
  13. strcpy(instr[2], "黄");
  14. strcpy(instr[3], "金");
  15.  
  16. for (i = 0; i <= 2; i++) {
  17. for (j = 0; j <= 11; j++) {
  18. for (k = 0; k <= 2; k++) {
  19. if (!(instr[i][k] == strc[j][k])) {
  20. goto A1;
  21. }
  22. }
  23. C[i] = j;
  24. A1:;
  25. }
  26. }
  27.  
  28. i = 2;
  29. for (j = 0; j <= 11; j++) {
  30. for (k = 0; k <= 2; k++) {
  31. if (!(instr[i][k] == strc[j][k])) {
  32. goto A2;
  33. }
  34. }
  35. b = j;
  36. A2:;
  37. }
  38.  
  39. i = 3;
  40. for (j = 0; j <= 11; j++) {
  41. for (k = 0; k <= 2; k++) {
  42. if (!(instr[i][k] == strc[j][k])) {
  43. goto A3;
  44. }
  45. }
  46. p = j;
  47. A3:;
  48. }
  49.  
  50. printf("%d %d %d %d\n", C[0], C[1], b, p);
  51. printf("抵抗値=%d×10^(%d)[Ω] 精度=%.2f[%%]\n", 10 * C[0] + C[1], bai[b], pre[p]);
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
2 1 4 10
抵抗値=21×10^(4)[Ω]  精度=5.00[%]