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