М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
ivanovaizl
ivanovaizl
31.12.2022 08:20 •  Информатика

Составить массив-константу на 5 чисел ,

👇
Ответ:
саят17
саят17
31.12.2022
На паскале, ведь Вам влом указать язык :)
const mas:array[1..5] of integer = (1,2,3,4,5);
4,5(97 оценок)
Открыть все ответы
Ответ:
Lorosa
Lorosa
31.12.2022
У меня есть какие-то наработки, они под линукс, но на винде должно работать все, кроме управления цветом, его выкинешь.

#include <cstdlib>#include <string>#include <iostream>#include "field.h"using namespace std;
int main(int argc, char** argv, char** env){    srand(time(0));    vector< vector< string > > S;    S.resize(2);    S[0].push_back("Vremena_goda");    S[1].push_back("Zima"); S[1].push_back("Vesna"); S[1].push_back("Leto"); S[1].push_back("Osen");
    Field A(S, Field().clGreen, Field().clLightblue);    cout << A << std::endl;    return 0;}
#ifndef FIELD_H_INCLUDED#define FIELD_H_INCLUDED
#include <vector>#include <iterator>#include <algorithm>#include <string>#include <sstream>class Field{public:    enum ConsoleColor { clBlack, clRed, clGreen, clYellow, clBlue, clPurple, clLightblue, clWhite };private:    size_t field_width, field_height;    std::vector< std::vector< std::string > > Data;    std::vector< size_t > column_width;    ConsoleColor color_border, color_font;    std::string get_format_color_string(std::string S, ConsoleColor color)    {        std::stringstream result;        result << "\x1b[1;" << color + 30 << "m" << S << "\x1b[0m";        return result.str();    }    std::string str_mul(std::string s, size_t num)    {        std::string result = "";        for(size_t i = 0; i < num; i++)            result += s;        return result;    }public:    Field() {};    Field(std::vector< std::vector< std::string > > D,          ConsoleColor color_border,          ConsoleColor color_font) :        Data(D), color_border(color_border), color_font(color_font)    {        field_height = Data.size();        field_width = 0;        for(size_t i = 0; i < field_height; i++)            field_width = std::max(field_width, Data[i].size());        for(size_t i = 0; i < field_height; i++)            while(Data[i].size() < field_width)                Data[i].push_back("");        column_width.assign(field_width, 0);        for(size_t i = 0; i < field_height; i++)            for(size_t j = 0; j < field_width; j++)                column_width[j] = std::max(column_width[j], Data[i][j].length());    }    void logs()    {        std::cout << "field_height: " << field_height << std::endl;        std::cout << "field_widht: " << field_width << std::endl;    }    friend std::ostream& operator <<(std::ostream& output_stream, Field & field)    {        /*        std::cout << field.field_width << " " << field.field_height << std::endl;        for(size_t i = 0; i < field.Data.size(); i++)        {            for(size_t j = 0; j < field.Data[i].size(); j++)                std::cout << field.Data[i][j] << " ";            std::cout << std::endl;        }        */
        output_stream << field.get_format_color_string("        ┌", field.color_border);        for(size_t i = 0; i < field.field_width - 1; i++)        {            output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[i] + 2), field.color_border);            output_stream << field.get_format_color_string("┬", field.color_border);        }        output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[field.field_width - 1] + 2), field.color_border);        output_stream << field.get_format_color_string("┐\n        ", field.color_border);
        for(size_t i = 0; i < field.field_height; i++)        {            output_stream << field.get_format_color_string("│", field.color_border);            for(size_t j = 0; j < field.field_width; j++)            {                std::stringstream ss;                ss << field.str_mul(" ", field.column_width[j] - field.Data[i][j].size() + 1) << (field.Data[i][j] != "" ? field.Data[i][j] : "");                output_stream << field.get_format_color_string(ss.str(), field.color_font);                output_stream << field.get_format_color_string(" │", field.color_border);            }            output_stream << "\n        ";            if(i != field.field_height - 1)            {                output_stream << field.get_format_color_string("├", field.color_border);                for(size_t j = 0; j < field.field_width - 1; j++)                {                    output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[j] + 2), field.color_border);                    output_stream << field.get_format_color_string("┼", field.color_border);                }                output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[field.field_width - 1] + 2), field.color_border);                output_stream << field.get_format_color_string("┤", field.color_border);            }            else            {                output_stream << field.get_format_color_string("└", field.color_border);                for(size_t j = 0; j < field.field_width - 1; j++)                {                    output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[j] + 2), field.color_border);                    output_stream << field.get_format_color_string("┴", field.color_border);                }                output_stream << field.get_format_color_string(field.str_mul("─", field.column_width[field.field_width - 1] + 2), field.color_border);                output_stream << field.get_format_color_string("┘\n", field.color_border);            }            output_stream << "\n        ";        }        return output_stream;
    }};
#endif // FIELD_H_INCLUDED
4,5(80 оценок)
Ответ:
danil1337Elit
danil1337Elit
31.12.2022
1) 1023 = 1111111111, 10 единиц
2) 501 = 111110101, 2 значащих нуля

Решение

Первая задача
Из десятичной в двоичную можно переводить двумя
1.      Сразу переводить в двоичную делением.
2.      Переводить в 16-ичную, после уже в двоичную.

Первый
В скобках высчитывается остаток от деления.
1)      1023 div 2 = 511 (1023 – (511*2) = 1)
2)      511 div 2 = 255 (511 – (255*2) = 1)
3)      255 div 2 = 127 (255 – (127*2) = 1)
4)      127 div 2 = 63 (127 – (63*2) = 1)
5)      63 div 2 = 31 (63 – (31*2) = 1)
6)      31 div 2 = 15 (31 – (15*2) = 1)
7)      15 div 2 = 7 (15 – (7*2) = 1)
8)      7 div 2 = 3 (7 – (2*3) = 1)
9)      3 div 2 = 1 (3 – (1*2) = 1)
Итого 1023 (10) = 1111111111 (2)  

Второй сначала переводим в 16-ичную
1)      1023 div 16 = 63 (1023 – (63*16) = 15)
2)      63 div 16 = 3 (63 – (3*16) = 15)
3 (16) = 0011 (2)
15 = F (16) = 1111 (2)
1023 (10) = 3FF (16) = 001111111111 (2)
Отбрасываем незначащие нули в начале числа и получаем 1111111111 (2)


Вторая задача
Во втором задании перевод так же можно совершить 2мя но я воспользуюсь вторым, так как он короче и быстрее.
1)      501 div 16 = 31 (501 – (31*16) = 5)
2)      31 div 16 = 1 (31 – (1*16) = 15)
1 (16) = 0001 (2)
5 (16) = 0101 (2)
15 = F (16) = 1111 (2)
501 (10) = 1F5 (16) = 000101011111 (2).
Отбрасываем незначащие нули в начале числа, получаем 101011111 (2)
4,8(63 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ