
Добавил:
aiko98aiko
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:ОргЭВМ(лабы 1-5) / laba1Середа
.cpp// ConsoleApplication2.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <list>
using namespace std;
string FunctionInt2(short int a)
{
vector<char> vector;
while (a != 0)
{
char ost = a % 2;
vector.insert(vector.begin(), ost == 0 ? '0' : '1');
a /= 2;
}
size_t Length = vector.size();
size_t zero_number = sizeof(short int) * 8 - Length;
for (size_t i = 0; i < zero_number; i++)
{
vector.insert(vector.begin(), '0');
}
string result(vector.begin(), vector.end());
return result;
}
string FunctionDouble(double b)
{
bool S;
if (b > 0)
bool S = 0;
else
S = 1;
int cel = floor(b);
double drob = b - cel;
}
int main()
{
setlocale(LC_ALL, "Russian");
int k = static_cast<int>((pow(2, sizeof(short int) * 8.0 - 1) - 1));
int x;
cout << "Введите число short int";
cin >> x;
if ((x > k) || (x < -(k + 1)))
cout << "Число выходит за границы диапазона short int";
else
cout << FunctionInt2(x)<<endl;
system("Pause");
return 0;
}
Соседние файлы в папке ОргЭВМ(лабы 1-5)