fdsfsf

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.4 kB
2
Indexable
Never

#include <iostream>
#include <Windows.h>

void clear() {
	COORD topLeft = { 0, 0 };
	HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO screen;
	DWORD written;

	GetConsoleScreenBufferInfo(console, &screen);
	FillConsoleOutputCharacterA(
		console, ' ', screen.dwSize.X * screen.dwSize.Y, topLeft, &written
	);
	FillConsoleOutputAttribute(
		console, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE,
		screen.dwSize.X * screen.dwSize.Y, topLeft, &written
	);
	SetConsoleCursorPosition(console, topLeft);
}

int HEX_TO_DEC(char st[10])
{
	int i, s, k, p;
	s = 0;
	p = strlen(st) - 1;
	for (i = 0; st[i] != '\0'; i++)
	{
		switch (toupper(st[i]))
		{
		case 'A': k = 10; break;
		case 'B': k = 11; break;
		case 'C': k = 12; break;
		case 'D': k = 13; break;
		case 'E': k = 14; break;
		case 'F': k = 15; break;
		case '1': k = 1; break;
		case '2': k = 2; break;
		case '3': k = 3; break;
		case '4': k = 4; break;
		case '5': k = 5; break;
		case '6': k = 6; break;
		case '7': k = 7; break;
		case '8': k = 8; break;
		case '9': k = 9; break;
		case '0': k = 0; break;
		}
		s = s + k * pow(16, p);
		p--;
	}
	std::cout << s;
	return 0;
}

void EIGHT_TO_DEC() {

	{char S[255];
	int l, z, k, i;
	float n;
	float c;
	printf("vvedite 8: ");
	std::cin >> S;
	c = 0;
	for (i = 0;i < strlen(S); i++)
	{
		if (S[i] == '.')
			break;
		switch (S[i]) {
		case '0': z = 0;break;
		case '1': z = 1;break;
		case '2': z = 2; break;
		case '3': z = 3; break;
		case '4': z = 4; break;
		case '5': z = 5; break;
		case '6': z = 6; break;
		case '7': z = 7; break;
		default:
			std::cout << "Nepravilni vvod" << std::endl;
		}
		c = c * 8 + z;
	}

	std::cout << c << std::endl;
	if (i = '.')
		float drob(int k, char* S);
	char* t = strchr(S, '.');
	k = t - S;
	float j = 16;
	float s = 0;
	for (i = k + 1;i < strlen(S);i++)
	{
		if (S[i] <= 56)
		{
			s = ((int)S[i] - 48) / j;
			j = j * 8;
		}
	}
	n = c + s;
	clear();
	std::cout << n << " " << std::endl;
	}

}

void DOUBLE_TO_DEC() {
	long long n;
	std::cout << "Vvedite chislo: ";
	std::cin >> n;
	int dec = 0, i = 0, rem;

	while (n != 0) {
		rem = n % 10;
		n /= 10;
		dec += rem * pow(2, i);
		++i;
	}

	std::cout << DOUBLE_TO_DEC(n) << " in decimal";


}

int main()
{
	
	
	return 0;
}