Няшная / Говнокод #28950 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  97. 97
  98. 98
  99. 99
  100. 100
/*
 Brainfuck-C ( http://github.com/kgabis/brainfuck-c )
 Copyright (c) 2012 Krzysztof Gabis
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#include <stdio.h>

#define OP_END          0
#define OP_INC_DP       1
#define OP_DEC_DP       2
#define OP_INC_VAL      3
#define OP_DEC_VAL      4
#define OP_OUT          5
#define OP_IN           6
#define OP_JMP_FWD      7
#define OP_JMP_BCK      8

#define SUCCESS         0
#define FAILURE         1

#define PROGRAM_SIZE    4096
#define STACK_SIZE      512
#define DATA_SIZE       65535

#define STACK_PUSH(A)   (STACK[SP++] = A)
#define STACK_POP()     (STACK[--SP])
#define STACK_EMPTY()   (SP == 0)
#define STACK_FULL()    (SP == STACK_SIZE)

struct instruction_t {
    unsigned short operator;
    unsigned short operand;
};

static struct instruction_t PROGRAM[PROGRAM_SIZE];
static unsigned short STACK[STACK_SIZE];
static unsigned int SP = 0;

int compile_bf(FILE* fp) {
    unsigned short pc = 0, jmp_pc;
    int c;
    while ((c = getc(fp)) != EOF && pc < PROGRAM_SIZE) {
        switch (c) {
            case '>': PROGRAM[pc].operator = OP_INC_DP; break;
            case '<': PROGRAM[pc].operator = OP_DEC_DP; break;
            case '+': PROGRAM[pc].operator = OP_INC_VAL; break;
            case '-': PROGRAM[pc].operator = OP_DEC_VAL; break;
            case '.': PROGRAM[pc].operator = OP_OUT; break;
            case ',': PROGRAM[pc].operator = OP_IN; break;
            case '[':
                PROGRAM[pc].operator = OP_JMP_FWD;
                if (STACK_FULL()) {
                    return FAILURE;
                }
                STACK_PUSH(pc);
                break;
            case ']':
                if (STACK_EMPTY()) {
                    return FAILURE;
                }
                jmp_pc = STACK_POP();
                PROGRAM[pc].operator =  OP_JMP_BCK;
                PROGRAM[pc].operand = jmp_pc;
                PROGRAM[jmp_pc].operand = pc;
                break;
            default: pc--; break;
        }
        pc++;
    }
    if (!STACK_EMPTY() || pc == PROGRAM_SIZE) {
        return FAILURE;
    }
    PROGRAM[pc].operator = OP_END;
    return SUCCESS;
}

int execute_bf() {
    unsigned short data[DATA_SIZE], pc = 0;
    unsigned int ptr = DATA_SIZE;
    while (--ptr) { data[ptr] = 0; }
    while (PROGRAM[pc].operator != OP_END && ptr < DATA_SIZE) {
// (...)

Интерпретатор Brainfuck.

Полный код можно посмотреть тута:
https://github.com/kgabis/brainfuck-c/blob/master/brainfuck.c

kNode kNode, (Updated )

Комментарии (6, +6)

Няшная / Говнокод #28923 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  97. 97
  98. 98
  99. 99
template <typename Key, typename Value, size_t TblPower = 2>
struct HashMap {
	struct Node
	{
		Key k;
		Value v;
		Node *n;

		Node(const Key &key, const Value &value) :
			k(key), v(value), n(NULL) {}

		Node(const Key &key) :
			k(key), v(), n(NULL) {}
	};

	constexpr static size_t TblSize = 1U << TblPower;
	Node *table[TblSize] = {nullptr};

	HashMap() {
	}

	~HashMap() {
		for(size_t i = 0; i < TblSize; i++)
		{
			Node *entry = table[i];
			while(entry)
			{
				Node *prev = entry;
				entry = entry->n;
				delete prev;
			}
			table[i] = NULL;
		}
	}

	size_t HashFunc(const Key &key) const
	{
		/// TODO: string hash?
		// handle hash: handle pointers usually aligned
		return (((size_t) key) >> 8)  & (TblSize - 1);
	}

	// just in case: check existance or constant access
	forceinline Value *GetPtr(const Key &key) const
	{
		size_t hashValue = HashFunc(key);
		Node *entry = table[hashValue];
		while(likely(entry))
		{
			if(entry->k == key)
				return &entry->v;
			entry = entry->n;
		}
		return nullptr;
	}

	Value &operator [] (const Key &key)
	{
		return GetOrAllocate(key);
	}

#define HASHFIND(key) \
		size_t hashValue = HashFunc(key); \
		Node *prev = NULL; \
		Node *entry = table[hashValue]; \
	\
		while(entry && entry->k != key) \
		{ \
			prev = entry; \
			entry = entry->n; \
		}

	Node * noinline _Allocate(Key key, size_t hashValue, Node *prev, Node *entry)
	{
		entry = new Node(key);
		if(unlikely(!entry))
		{
			static Node error(key);
			return &error;
		}

		if(prev == NULL)
			table[hashValue] = entry;
		else
			prev->n = entry;
		return entry;
	}

	Value& GetOrAllocate(const Key &key)
	{
		HASHFIND(key);

		if(unlikely(!entry))
			entry = _Allocate(key,hashValue, prev, entry);

		return entry->v;
	}
// тут был ещё один метод, но в говнокод не влез
}

когда СГОРЕЛО от STL

mittorn mittorn, (Updated )

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

Няшная / Говнокод #28922 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
struct HashArrayMap {

	struct Node
	{
		Key k;
		Value v;

		Node(const Key &key, const Value &value) :
			k(key), v(value){}
		Node(const Key &key) :
			k(key), v(){}
	};

	constexpr static size_t TblSize = 1U << TblPower;
	GrowArray<Node> table[TblSize];

	HashArrayMap() {
	}

	~HashArrayMap() {
	}

	size_t HashFunc(const Key &key) const
	{
		/// TODO: string hash?
		// handle hash: handle pointers usually aligned
		return (((size_t) key) >> 8)  & (TblSize - 1);
	}

	// just in case: check existance or constant access
	Value *GetPtr(const Key &key) const
	{
		size_t hashValue = HashFunc(key);
		const GrowArray<Node> &entry = table[hashValue];
		for(int i = 0; i < entry.count; i++)
		{
			if(entry[i].k == key)
				return &entry[i].v;
		}
		return nullptr;
	}

	Value &operator [] (const Key &key)
	{
		return GetOrAllocate(key);
	}

#define HASHFIND(key) \
	GrowArray<Node> &entry = table[HashFunc(key)]; \
	int i; \
	for(i = 0; i < entry.count; i++) \
		if( entry[i].k == key ) \
			break;

	Value& GetOrAllocate(const Key &key)
	{
		HASHFIND(key);
		if(i == entry.count )
			entry.Add(Node(key));

		return entry[i].v;
	}

	bool Remove(const Key &key)
	{
		HASHFIND(key);
		if(i != entry.count)
		{
			entry.RemoveAt(i);
			return true;
		}
		return false;
	}
#undef HASHFIND
};

когда СГОРЕЛО от STL

mittorn mittorn, (Updated )

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

Няшная / Говнокод #28921 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
template<class T>
struct GrowArray
{
	T *mem = nullptr;
	size_t count = 0;
	size_t alloc = 0;

	GrowArray(size_t init = 0)
	{
		if(init)
			Grow(init);
	}
	~GrowArray()
	{
		if(mem)
			free(mem);
		mem = nullptr;
		count = 0;
		alloc = 0;
	}

	// non-copyable
	GrowArray(const GrowArray &) = delete;
	GrowArray &operator = (const GrowArray &) = delete;

	void noinline Grow(size_t size)
	{
		if(!size)
			size = 32;
		T *newMem = (T*)(mem? realloc(mem, sizeof(T) * size): malloc(sizeof(T)*size));

		if(!newMem)
			return;

		alloc = size;
		mem = newMem;
	}

	// TODO: insert/append
	bool Add(const T& newVal)
	{
		size_t newIdx = count + 1;
		if(unlikely(newIdx > alloc))
			Grow(alloc * 2);
		if(unlikely(newIdx > alloc))
			return false;
		mem[count] = newVal;
		count = newIdx;
		return true;
	}

	// TODO: test
	bool RemoveAt(size_t idx)
	{
		if(idx < count)
			memmove(&mem[idx], &mem[idx+1], sizeof(T) * (count - idx - 1));
		if(idx <= count)
		{
			count--;
			return true;
		}
		return false;
	}
	T& operator[](size_t i) const
	{
		return mem[i];
	}
};

mittorn mittorn, (Updated )

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

Няшная / Говнокод #28887 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
#include <windows.h>

#define PL 7	//длинна пароля

const char F[] = "`1234567890-=\\qwertyuiop[]asdfghjkl;'zxcvbnm,./";
const char N[] = "1`2q1qw32we43er54rt65ty76yu87ui98io09op-0p[=-[]\\=]12wa23esaq34rdsw45tfde56ygfr67uhgt78ijhy89okju90plki0-[;lo-=]';p=\\'[qwszwedxzaerfcxsrtgvcdtyhbvfyujnbguikmnhiol,mjop;.,kp['/.l[]/;asxsdczxdfvcfgbvghnbhjmnjk,mkl.,l;/.;'";
const char L[] = { 1, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3 };

struct _
{
	char P[PL + 1];
	BYTE I[256], O[48];
};

void __stdcall $(int n, char c, _ *X)
{
	X->P[n++] = c;
	for (int i = 0; n < PL && i < L[X->I[c]]; $(n, N[X->O[X->I[c]] + i++], X));
	for (int i = 0, d = 0, l = 0, s = 0; n == PL && i < n; (X->P[i] >= '0' && X->P[i] <= '9') ? d++ : (X->P[i] >= 'a' && X->P[i] <= 'z') ? l++ : s++, (d && l && s) ? _lwrite(-11, X->P, ++n), i = n : i++);
}

void main()
{
	_ w;

	w.P[PL] = '\n';

	for (int i = 0; i < 47; w.I[F[i]] = i, w.O[i] = i ? w.O[i - 1] + L[i - 1] : 0, i++);
	for (int i = 0; i < 47; $(0, F[i++], &w));
}

Генератор сложных (буквы, цифры, символы) паролей с выводом в консоль.
Выводит ВСЕ пароли заданной длинны, которые можно ввести по соседним клавишам без шифта. Всякие лесенки, зигзаги и т.п., т.е. все плохие...
В main переименовал, чтоб скомпилировать. Релизный exe-шник сразу стёр антивирус, сказал Trojan:Win32/Wacatac.B!ml
Обфускаторы рулят :)

sprog sprog, (Updated )

Комментарии (2, +2)

Няшная / Говнокод #28872 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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 gne4do, (Updated )

Комментарии (4, +4)

Няшная / Говнокод #28871 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  97. 97
  98. 98
  99. 99
  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 gne4do, (Updated )

Комментарии (8, +8)

Няшная / Говнокод #28870 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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 gne4do, (Updated )

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

Няшная / Говнокод #28869 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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 gne4do, (Updated )

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