Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
533 B
0
Indexable
Never
#include <iostream>
using namespace std;
#include <SFML/Graphics.hpp>
#include <conio.h>
#include <stdio.h>
#include <cstdlib> 
#include <time.h> 
#include <cmath>


int main()
{
	int a;

	int k;

	int suma = 0;

	int b[8] = {}; // массив для перевода

	cin >> a;

	cin >> k;

	for (int i = 0; i < 8; i++) { b[i] = a % 2; a /= 2; cout << b[i] << "\n"; }

	for (int i = 0; i < 8 - k; i++)
	{
		b[i] = 0;
	}

	for (int i = 0; i < 8; i++){suma += b[i] * pow(2, i);}

	cout << suma;

}
Leave a Comment