1. Список говнокодов пользователя gne4do

    Всего: 25

  2. Си / Говнокод #28872

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    void branch(int *cnt, int accum, int nxt, int comn) {
      printf("accum %d %d\n", accum, comn);
      if (accum < 0 && comn == 41) {
        *cnt = nxt;
      } else if (accum == 0 && comn == 42) {
        *cnt = nxt;
      } else if (comn == 40) {
        *cnt = nxt;
      }
    
      else {
        (*cnt)++;
      }
    }
    
    
    void dump(int word[]) {
      int d = 0, x;
      printf("%3c", ' ');
      while (d != 10) {
        printf("%5d ", d);
        d++;
      }
      for (d = 0; d != MEM; d++) {
        x = word[d];
        if (0 == (d % 10))
          puts(" "), printf("%3d", d);
        printf(x >= 0 ? " +%.4X" : " %.4d", x);
      }
      puts(" ");
    }
    
    void dump_file(int word[]) {
      int d = 0, x;
      FILE *flrun;
      flrun = fopen("wrt.txt", "w+");
    
      fprintf(flrun, "%3c", ' ');
      while (d != 10) {
        fprintf(flrun, "%5d ", d);
        d++;
      }
      for (d = 0; d != MEM; d++) {
        x = word[d];
        if (0 == (d % 10))
          fprintf(flrun, "\n"), fprintf(flrun, "%3d", d);
        fprintf(flrun, x >= 0 ? " +%.4X" : " %.4d", x);
      }
    }
    
    long long_var(long var) {
      long step = 1;
      do {
        step *= 10;
      } while (var /= step);
      return (step / 10);
    }

    Демотрон 3
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (4)
  3. Си / Говнокод #28871

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    fclose(cfPtr);
    
      while ((mem[operand] > -9999) && (mem[operand] < 9999) && sign != 1) {
    
        ins_rgr = (mem[ins_cnt]);
    
        op_code = (ins_rgr / 100);
        operand = (ins_rgr % 100);
        // printf("op_code = %d   operand = %d  acc = %d\n", op_code, operand , acc
        // );
        //    dump(mem);
    
        switch (op_code) {
    
        case HALT:
          sign = 1;
          break;
    
        case READ:
          printf("? read ");
    
          scanf("%d", &buf);
          mem[operand] = buf;
    
          ins_cnt++;
          break;
    
        case WRITE:
          printf("%d\n", mem[operand]);
          ins_cnt++;
          break;
    
        case LOAD:
    
          acc = mem[operand];
          ins_cnt++;
          break;
    
        case STORE:
    
          mem[operand] = acc;
          ins_cnt++;
          break;
    
        case ADD:
    
          acc += mem[operand];
          ins_cnt++;
          break;
    
        case SUBSTRACT:
    
          acc -= mem[operand];
          ins_cnt++;
    
          break;
    
        case DIVIDE:
    
          acc /= mem[operand];
          ins_cnt++;
          break;
    
        case MUL:
    
          acc *= mem[operand];
          ins_cnt++;
          break;
    
        case POW:
          acc = pow(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case MOD:
          acc = fmod(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case NEWLINE:
          puts(" ");
          ins_cnt++;
          break;
    
        case BRANCH:
        case BRANCHZERO:
        case BRANCHNEG:
       
          branch(&ins_cnt, acc, operand, op_code);
    
          break;
    
         
        }
      }
    
      dump(mem);
      dump_file(mem);
      puts(" ");
    }

    Демотрон 2
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (8)
  4. Си / Говнокод #28870

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    #include <ctype.h>
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define MEM 100
    #define READ 10
    #define WRITE 11
    #define LOAD 20
    #define STORE 21
    #define NEWLINE 22
    #define ADD 30
    #define SUBSTRACT 31
    #define DIVIDE 32
    #define MUL 33
    
    #define POW 34
    #define MOD 35
    
    #define ENTSTR 50
    
    #define PRTSTR 51
    
    #define BRANCH 40
    #define BRANCHNEG 41
    #define BRANCHZERO 42
    #define HALT 43
    int main(int argc, char *argv[]) {
      void dump_file(int word[]);
    
      FILE *cfPtr;
    
      // char buf[5];
      void branch(int *cnt, int accum, int nxt, int comn);
      int buf_mem[100] = {0};
      void dump(int word[]);
      int x = 0, y = 0, s = 0;
      // int mem[MEM] = {0};
      int mem[MEM];
    
      for (; x != MEM; x++) {
        mem[x] = 0;
      }
    
      int acc = 0, d = 0;
      int ins_cnt = 0, ins_rgr = 0, op_code = 0, operand = 0, buf = 0;
    
      int b = 0, l, r = 0, m = 0, ti = 0, sign = 0;
    
      cfPtr = fopen(argv[1], "r");
    
      for (; feof(cfPtr) == 0;) {
        fscanf(cfPtr, "%d %d\n", &b, &l);
        mem[b] = l;
      
      }

    Демотрон 1
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (0)
  5. Си / Говнокод #28869

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    int let_past(data *base, char *infix, char *post_infix) {
      char *buffer;
    
      int past_in_table_cons_or_value(data * table, char *str_tok);
      int data_adress = 0;
      int lng = 0;
      int left_side = 0;
    
      past_in_table_cons_or_value(base, &infix[0]);
    
      buffer = strtok(&infix[1], "  ");
    
      for (; buffer != (char *)'\0';
           post_infix[lng++] = ' ', buffer = strtok(NULL, " ")) {
    
        if (isalnum(*buffer)) {
    
          data_adress = past_in_table_cons_or_value(base, buffer);
    
          sprintf(&post_infix[lng], "%d", data_adress);
    
          lng += 2;
        }
    
        else {
          post_infix[lng] = *buffer;
          lng++;
        }
      }
    
      post_infix[lng] = '\0';
      left_side = search_in_table(base, &infix[0]);
    
      return (base + left_side)->location;
    }
    
    int my_strcmp (const char *out, const char *in   ){
      for( ;*(in) , *(out) &&  *(in) == *(out); *out++,*in++  );
    	   return   *in <= *out ?  *out > *in   : -1   ;
    	}

    Инклуды длясимплтрона 4

    gne4do, 02 Октября 2023

    Комментарии (0)
  6. Си / Говнокод #28868

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    int pop_2(StackNodePtr_2 *topPtr) {
      StackNodePtr_2 tempPtr;
      int popValue;
    
      tempPtr = *topPtr;
      popValue = (*topPtr)->data;
      *topPtr = (*topPtr)->nextPtr;
      free(tempPtr);
    
      return popValue;
    }
    
    /* Return the value at the top of the stack */
    char stackTop_1(StackNodePtr_2 topPtr) {
      char topValue;
    
      topValue = topPtr->data;
    
      return topValue;
    }
    
    int isEmpty_2(StackNodePtr_2 topPtr) { return topPtr == NULL; }
    
    /* Test if the list is empty */
    
    int my_isalpha(char alpha) {
      return ((alpha >= 65 && alpha <= 90) || (alpha >= 97 && alpha <= 122));
    }
    
    int my_isdigit(char alpha) { return (alpha >= 48) && (alpha <= 57); }
    
    int isOperator_2(char c) {
    
      return c == '/' || c == '*' || c == '-' || c == '+' || c == '^' || c == '%';
    }
    
    int goto_search(data *table, char *token) {
    
      int x = 0;
    
      for (x = 0; x != 100; x++) {
    
        if (memcmp((table + x)->symbol, token, 2) == 0) {
          return (table + x)->location;
        }
      }
      return 0;
    }
    
    int helper_search_1(data *base, char *token, int run) {
      return ((base + run)->symbol[0] == *token ||
              my_strcmp((base + run)->symbol, "0") == 0);
    }
    
    int helper_search_2(data *base, char *token, int run) {
      return (my_strcmp((base + run)->symbol, token) == 0 ||
              my_strcmp((base + run)->symbol, "0") == 0);
    }
    
    int search_in_base(data *intro_search, char *str_tok_search) {
    
      int runner = 0, ch = !my_isalpha(*str_tok_search);
      for (; !helper_search_base(intro_search, str_tok_search, runner); ++runner)
        ;
      return runner;
    }
    int helper_search_base(data *base, char *token, int run) {
      return my_strcmp((base + run)->symbol, "0") == 0;
    }
    
    int search_in_table(data *intro_search, char *str_tok_search) {
    
      int runner = 0, ch = !my_isalpha(*str_tok_search);
      for (; !(*helper_search[ch])(intro_search, str_tok_search, runner); ++runner)
        ;
      return runner;
    }
    
    int rem_break(char *token) {
    
      if (memcmp(token, "rem", 3) == 0) {
        return 1;
      }
      return 0;
    }

    Инклуды для симплтрона

    gne4do, 02 Октября 2023

    Комментарии (0)
  7. Си / Говнокод #28867

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    /* Do the conversion */
      while (!isEmpty_2(stackPtr) && infix[i] != '\0') {
        c = infix[i++];
    
        if (my_isdigit(c) || my_isalpha(c)) {
          while (my_isdigit(c) || my_isalpha(c)) {
            postfix[j++] = c;
            c = infix[i++];
          }
          postfix[j++] = ' ';
    
          if (c == ')' || isOperator_2(c))
            i--;
        } else if (c == '(')
          push_2(&stackPtr, '(');
        else if (isOperator_2(c) == 1) {
          if (!isEmpty_2(stackPtr) && isOperator_2(stackTop_1(stackPtr))) {
            while (isOperator_2(stackTop_1(stackPtr)) &&
                   (precedence_1(stackTop_1(stackPtr), c)) >= 0) {
              postfix[j++] = pop_2(&stackPtr);
              postfix[j++] = ' ';
            }
            push_2(&stackPtr, c);
          } else
            push_2(&stackPtr, c);
        } else if (c == ')') {
          if (!isEmpty_2(stackPtr)) {
            c = pop_2(&stackPtr);
    
            while (!isEmpty_2(stackPtr) && c != '(') {
              postfix[j++] = c;
              postfix[j++] = ' ';
              c = pop_2(&stackPtr);
            }
          }
        }
      }
      postfix[j] = '\0';
    }
    
    int precedence_1(char operator1, char operator2) {
      int result = 1;
    
      switch (operator1) {
      case '^':
        if (operator2 == '^')
          result = 0;
        break;
      case '*':
      case '/':
      case '%':
        switch (operator2) {
        case '^':
          result = -1;
          break;
        case '*':
        case '/':
        case '%':
          result = 0;
          break;
        default:
          break;
        }
        break;
      case '+':
      case '-':
        switch (operator2) {
        case '-':
        case '+':
          result = 0;
          break;
        default:
          result = -1;
          break;
        }
        break;
      }
    
      return result;
    }
    
    void push_2(StackNodePtr_2 *topPtr, int info) {
      StackNodePtr_2 newPtr;
    
      newPtr = malloc(sizeof(StackNode_2)); /* Now points to a place in memory*/
    
      if (newPtr != NULL) {
        newPtr->data = info;
        newPtr->nextPtr = *topPtr;
        *topPtr = newPtr;
      } else
        printf("%c not inserted. No memory available.\n", info);
    }

    Инклуды для симплтрона 2

    gne4do, 02 Октября 2023

    Комментарии (0)
  8. Си / Говнокод #28866

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    #include <ctype.h> 
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define MEM 100
    #define READ 10
    #define WRITE 11
    #define LOAD 20
    #define STORE 21
    #define ADD 30
    #define SUBSTRACT 31
    #define DIVIDE 32
    #define MUL 33
    #define BRANCH 40
    #define BRANCHNEG 41
    #define BRANCHZERO 42
    #define HALT 43
    
    int count_down = 99;
    
    struct stackNode_2 {
      int data;
      struct stackNode_2 *nextPtr;
    };
    
    typedef struct stackNode_2 StackNode_2;
    typedef StackNode_2 *StackNodePtr_2;
    
    typedef struct tableEntry {
      char symbol[10];
      char type;
      int location;
    
    } data;
    
    int my_isdigit(char alpha);
    int my_isalpha(char alpha);
    int isOperator_2(char c);
    
    char stackTop_1(StackNodePtr_2 topPtr);
    
    int helper_search_1(data *base, char *token, int run);
    
    int helper_search_2(data *base, char *token, int run);
    
    int (*helper_search[2])(data *base, char *token, int run) = {helper_search_1,
                                                                 helper_search_2};
    
    int search_in_base(data *intro_search, char *str_tok_search);
    int helper_search_base(data *base, char *token, int run);
    
    void convertToPostfix_1(char infix[], char postfix[]);
    
    int pop_2(StackNodePtr_2 *topPtr);
    void push_2(StackNodePtr_2 *topPtr, int info);
    int isEmpty_2(StackNodePtr_2 topPtr);
    
    int precedence_1(char operator1, char operator2);
    
    void convertToPostfix_1(char infix[], char postfix[]) {
      int i = 0, j = 0;
      char c;
    
      /* Push left parenthesis to stack */
      StackNodePtr_2 stackPtr = NULL;
      push_2(&stackPtr, '(');
    
      /* Add right parenthesis to end of infix */
      while (infix[i] != '\0')
        i++;
    
      infix[i++] = ')';
      infix[i] = '\0';
    
      i = 0;

    Инклуды для симплтрона 1

    gne4do, 02 Октября 2023

    Комментарии (0)
  9. Си / Говнокод #28865

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    int calculate_2(int op1, int op2, char operator, int memory_smp[],
                    int *count_command) {
    
      int result = 0;
    
      switch (operator) {
      case '+':
    
        memory_smp[*count_command] = (2000 + op1);
        (*count_command)++;
    
        memory_smp[*count_command] = (3000 + op2);
        (*count_command)++;
    
        memory_smp[*count_command] = (2100 + count_down);
    
        (*count_command)++;
        result = count_down;
        count_down--;
    
        // result = op1 + op2;
        break;
      case '-':
        memory_smp[*count_command] = (2000 + op1);
        (*count_command)++;
        memory_smp[*count_command] = (3100 + op2);
        (*count_command)++;
        memory_smp[*count_command] = (2100 + count_down);
        (*count_command)++;
        result = count_down;
        count_down--;
        // result = op1 - op2;
        break;
      case '*':
        memory_smp[*count_command] = (2000 + op1);
        (*count_command)++;
        memory_smp[*count_command] = (3300 + op2);
        (*count_command)++;
        memory_smp[*count_command] = (2100 + count_down);
        (*count_command)++;
        result = count_down;
        count_down--;
        // result = op1 * op2;
        break;
      case '/':
    
        memory_smp[*count_command] = (2000 + op1);
        (*count_command)++;
        memory_smp[*count_command] = (3200 + op2);
        (*count_command)++;
        memory_smp[*count_command] = (2100 + count_down);
        (*count_command)++;
        result = count_down;
        count_down--;
        //   result = op1 / op2;
        break;
      /*
      case '^':
        result = pow(op1, op2);
        break;
      case '%':
        result = op1 % op2;
        break;
      */
      default:
        break;
      }
    
      return result;
    }

    Симлтрон из Дейтелов
    5

    gne4do, 02 Октября 2023

    Комментарии (0)
  10. Си / Говнокод #28864

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    file_buf = fopen(argv[2], "w");
    
      for (d = 0; mem_smp[d] != 0; d++) {
    
        fprintf(file_buf, "%d %d\n", d, mem_smp[d]);
      }
    
      for (d = 0; (symbolTable + d)->type != 'q'; d++) {
    
        if ((symbolTable + d)->type == 'C') {
          count_cmd = atoi((symbolTable + d)->symbol);
    
          fprintf(file_buf, "%d %d\n", (symbolTable + d)->location, count_cmd);
        }
      }
      fclose(file_buf);
    
      return 0;
    }
    
    int past_in_table_cons_or_value(data *table, char *str_tok) {
    
      int search_in_table(data * intro_search, char *str_tok_search);
    
      int find = search_in_table(table, str_tok);
    
      if ((table + find)->type == 'q') {
    
        if (my_isalpha(*str_tok)) {
          (table + find)->symbol[0] = *str_tok; //  or  str_tok don't atoi
    
        } else {
          strcpy((table + find)->symbol, str_tok);
        }
    
        (table + find)->type = my_isalpha(*str_tok) ? 'V' : 'C';
    
        (table + find)->location = count_down;
    
        count_down--;
      }
    
      return (table + find)->location;
    }
    
    int evaluatePostfixExpression_2(char *expr, int memory_smp[],
                                    int *count_command) {
      StackNodePtr_2 stackPtr = NULL;
      char c;
      int x, y;
      int i = 0, mult = 1, num = 0;
    
      while (expr[i] != '\0') {
        mult = 1;
        num = 0;
        c = expr[i];
        if (my_isdigit(c)) {
          while (my_isdigit(c)) {
            num *= mult;
            num += c - 48;
            c = expr[++i];
            mult *= 10;
          }
          --i;
          push_2(&stackPtr, num);
        } else if (isOperator_2(c)) {
          if (isEmpty_2(stackPtr)) {
            printf("Invalid postfix expression!\n");
            return 0;
          }
          x = pop_2(&stackPtr);
    
          if (isEmpty_2(stackPtr)) {
            printf("Invalid postfix expression!\n");
            return 0;
          }
          y = pop_2(&stackPtr);
    
          push_2(&stackPtr, calculate_2(y, x, c, memory_smp, &(*count_command)));
        }
        i++;
      }
    
      if (isEmpty_2(stackPtr)) {
        printf("Invalid postfix expression!\n");
        return 0;
      }
    
      return pop_2(&stackPtr);
    }
    
    int calculate_2(int op1, int op2, char operator, int memory_smp[],
                    int *count_command) {
    
      int result = 0;

    Симплтрон из задачи Дейтелов
    4

    gne4do, 02 Октября 2023

    Комментарии (0)
  11. Си / Говнокод #28863

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    if (sign_ch == 0) {
              swp = val_if[0];
              val_if[0] = val_if[1];
              val_if[1] = swp;
            }
    
            mem_smp[count_cmd] = 2000 + (symbolTable + val_if[1])->location;
            count_cmd++;
            mem_smp[count_cmd] = 3100 + (symbolTable + val_if[0])->location;
            count_cmd++;
    
            if (goto_flag == 1) {
              flags[count_cmd] = second_buf;
              mem_smp[count_cmd] = rn_data[ab].data[0];
              count_cmd++;
            } else {
              mem_smp[count_cmd] = rn_data[ab].data[0] + second_buf;
              count_cmd++;
            }
    
            if (rn_data[ab].type == 2) {
    
              mem_smp[count_cmd] = 2000 + (symbolTable + val_if[0])->location;
              count_cmd++;
              mem_smp[count_cmd] = 3100 + (symbolTable + val_if[1])->location;
              count_cmd++;
    
              if (goto_flag == 1) {
                flags[count_cmd] = second_buf;
                mem_smp[count_cmd] = rn_data[ab].data[1];
                count_cmd++;
              } else {
                mem_smp[count_cmd] = rn_data[ab].data[1] + second_buf;
                count_cmd++;
              }
            }
    
          }
    
          else if (my_strcmp(buffer, "goto") == 0) {
    
            second_buf = 0;
            goto_flag = 0;
    
            intro_buffer = strtok(NULL, " ");
            second_buf = goto_search(symbolTable, intro_buffer);
    
            if (second_buf == 0) {
              second_buf = atoi(intro_buffer);
              goto_flag = 1;
            }
    
            if (goto_flag == 1) {
              flags[count_cmd] = second_buf;
              mem_smp[count_cmd] = 4000;
              count_cmd++;
            } else {
              mem_smp[count_cmd] = 4000 + second_buf;
              count_cmd++;
            }
          }
    
          else if (my_strcmp(buffer, "print") == 0) {
            intro_buffer = strtok(NULL, " ");
            second_buf = search_in_table(symbolTable, intro_buffer);
            mem_smp[count_cmd] = 1100 + (symbolTable + second_buf)->location;
            count_cmd++;
    
          }
    
          else if (my_strcmp(buffer, "input") == 0) {
            intro_buffer = strtok(NULL, " ");
            past_in_table_cons_or_value(symbolTable, intro_buffer);
            second_buf = search_in_table(symbolTable, intro_buffer);
            mem_smp[count_cmd] = 1000 + (symbolTable + second_buf)->location;
            count_cmd++;
          } else if (my_strcmp(buffer, "end") == 0) {
    
            mem_smp[count_cmd] = 4300;
          }
    
          ////////////////////////////////////////////////////////////////////////
          count_table_extra = count_cmd;
          /////////////////////////////////////////////////////////////////////////
        }
      }
    
      for (d = 0; mem_smp[d] != 0; d++) {
        if (flags[d] != -1) {
    
          sprintf(&postfix[0], "%d", flags[d]);
    
          goto_flag = search_in_table(symbolTable, postfix);
          mem_smp[d] += (symbolTable + goto_flag)->location;
        }
      }

    Симплтрон из задачи Дейтелов
    3

    gne4do, 02 Октября 2023

    Комментарии (0)