switch.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2023 Jeremiah Orians
  2. * This file is part of M2-Planet.
  3. *
  4. * M2-Planet is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * M2-Planet is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. int match(char* a, char* b);
  18. int main(int argc, char** argv)
  19. {
  20. char* a = argv[1];
  21. int b = 0;
  22. if(match("test1", a))
  23. {
  24. b = 1;
  25. }
  26. else if(match("test2", a))
  27. {
  28. b = 3;
  29. }
  30. else if(match("test3", a))
  31. {
  32. b = 4;
  33. }
  34. else if(match("test4", a))
  35. {
  36. b = 6;
  37. }
  38. else if(match("test5", a))
  39. {
  40. b = 9;
  41. }
  42. else if(match("test6", a))
  43. {
  44. b = 8;
  45. }
  46. else if(match("test7", a))
  47. {
  48. b = 7;
  49. }
  50. int i = 31;
  51. switch(b)
  52. {
  53. case 0: return 111;
  54. case 1:
  55. case 2: return 122;
  56. case 3: break;
  57. case 4: i = 42;
  58. case 5: i = i + 1;
  59. break;
  60. case 7: i = i + 2;
  61. case 8: i = i + 1;
  62. case 9:
  63. switch(i)
  64. {
  65. case 31: return 133;
  66. case 32: i = 77;
  67. case 33: break;
  68. default: i = 144;
  69. }
  70. i = i + 7;
  71. break;
  72. default: return 155;
  73. }
  74. return i;
  75. }