/
TLX
/
DNA-Tools
Обзор
Документация
Войти
/
TLX
/
DNA-Tools
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
encode.c
91 строка
2 KB
TLX
Обновлен механизм разделения букв
09 окт 2025, 14:44
09 окт 2025, 14:44
0b22f65
Код
Авторство
О чём код?
#include <stdio.h> #include <stdint.h> #include <string.h> #include <malloc.h> #include <Windows.h> #include <locale.h> #define len(a) (sizeof(a)/sizeof(unsigned char)) // #define CC 4 #define SPLIT_CHAR '-' // ������� ��� �������������� ����������� ����� � ����� ������� ��������� void convertToBase(int number, int base, char *result) { int index = 0; char digits[] = "0123456789ABCDEF"; // ��������� ������������ ������ ����� 0 if (number == 0) { result[index++] = '0'; result[index] = '\0'; return; } // �������������� � �������������� ������� � �������� while (number > 0) { int remainder = number % base; result[index++] = digits[remainder]; number = number / base; } // ��������������� ������ result[index] = '\0'; for (int i = 0, j = index - 1; i < j; i++, j--) { char temp = result[i]; result[i] = result[j]; result[j] = temp; } } int main () { SetConsoleCP(1251);// ��������� ������� �������� win-cp 1251 � ����� ����� SetConsoleOutputCP(1251); setlocale(LC_ALL,"Russian"); char in[256] = {32}; char out[512] = {32}; // unsigned char // printf("%s\n%s\n", in, out); scanf("%s", &in); for (int i = 0; i<strlen(in); i++) { uint16_t code = in[i] - '0'; // wchar_t tmp[16]; char tmp[16]; convertToBase(code, 3, tmp); // wcscpy(tmp2, (wchar_t) tmp); for (int j = 0; j < strlen(tmp); j++) { switch (tmp[j] ) { case '0': tmp[j] = '�'; break; case '1': tmp[j] = '�'; break; case '2': tmp[j] = '�'; break; // case '3': // tmp[j] = '�'; // break; default: break; }; // if (tmp[j] == '0') { // tmp[j] = '�'; // } } // wchar_t tmp2 [16]; // mbstowcs(tmp2, tmp, 16); // uint16_t c = code; // printf("%s, ", &tmp); // wcscat(out, tmp); // swprintf(out, 256, L"%s%s-", out, tmp2); sprintf(out, "%s%s%c", out, tmp, SPLIT_CHAR); } printf("%s", out); }