fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int add(int,int);
  4. int minus(int,int);
  5. int main(void)
  6. {
  7. int a,b,f;
  8. printf("請輸入你的生日:");
  9. scanf("%d %d",&a,&b);
  10. f =(a-b)%10;
  11. if (f<0)
  12. f = f*-1;
  13. else
  14. f = f;
  15. switch(f)
  16. {
  17. case 0:printf("你的幸運色:黑\n");break;
  18. case 1:printf("你的幸運色:棕\n");break;
  19. case 2:printf("你的幸運色:紅\n");break;
  20. case 3:printf("你的幸運色:橙\n");break;
  21. case 4:printf("你的幸運色:黃\n");break;
  22. case 5:printf("你的幸運色:綠\n");break;
  23. case 6:printf("你的幸運色:藍\n");break;
  24. case 7:printf("你的幸運色:紫\n");break;
  25. case 8:printf("你的幸運色:灰\n");break;
  26. case 9:printf("你的幸運色:白\n");break;
  27. default:printf("輸入錯誤\n");break;
  28. }
  29. switch(a)
  30. {
  31. case 1:
  32. if (b>=21)
  33. printf("你的星座:水瓶座\n");
  34. else
  35. printf("你的星座:魔羯座\n");
  36. break;
  37. case 2:
  38. if (b>=20)
  39. printf("你的星座:雙魚座\n");
  40. else
  41. printf("你的星座:水瓶座\n");
  42. break;
  43. case 3:
  44. if (b>=21)
  45. printf("你的星座:牡羊座\n");
  46. else
  47. printf("你的星座:雙魚座\n");
  48. break;
  49. case 4:
  50. if (b>=20)
  51. printf("你的星座:金牛座\n");
  52. else
  53. printf("你的星座:牡羊座\n");
  54. break;
  55. case 5:
  56. if (b>=21)
  57. printf("你的星座:雙子座\n");
  58. else
  59. printf("你的星座:金牛座\n");
  60. break;
  61. case 6:
  62. if (b>=22)
  63. printf("你的星座:巨蟹座\n");
  64. else
  65. printf("你的星座:雙子座\n");
  66. break;
  67. case 7:
  68. if (b>=23)
  69. printf("你的星座:獅子座\n");
  70. else
  71. printf("你的星座:巨蟹座\n");
  72. break;
  73. case 8:
  74. if (b>=23)
  75. printf("你的星座:處女座\n");
  76. else
  77. printf("你的星座:獅子座\n");
  78. break;
  79. case 9:
  80. if (b>=23)
  81. printf("你的星座:天秤座\n");
  82. else
  83. printf("你的星座:處女座\n");
  84. break;
  85. case 10:
  86. if (b>=24)
  87. printf("你的星座:天蠍座\n");
  88. else
  89. printf("你的星座:天秤座\n");
  90. break;
  91. case 11:
  92. if (b>=22)
  93. printf("你的星座:射手座\n");
  94. else
  95. printf("你的星座:天蠍座\n");
  96. break;
  97. case 12:
  98. if (b>=21)
  99. printf("你的星座:魔羯座\n");
  100. else
  101. printf("你的星座:射手座\n");
  102. break;
  103. default:printf("輸入錯誤\n");break;
  104. }
  105. printf("你的幸運數字:%d\n",add(a,b));
  106. system("pause");
  107. }
  108. int add(int a,int b)
  109. {
  110. return 10-(a+b)%10;
  111. }
  112.  
Success #stdin #stdout #stderr 0s 9416KB
stdin
4
27
stdout
請輸入你的生日:你的幸運色:橙
你的星座:金牛座
你的幸運數字:9
stderr
sh: 1: pause: not found