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

переделать программу под задание(С++) #include

#include

using namespace std;

struct TREE {

int info, count;

TREE *left, *right;

};

TREE *root=NULL;

int flag=0;

int count=0;

TREE *Search(int info)

{

TREE *current=root;

flag=0;

while(current!=NULL && flag==0)

{

if(info info)

current=current->left;

else if(info>current->info)

current=current->right;

else

flag=1;

}

return current;

}

void Add(TREE **current, int info)

{

if(*current!=NULL)

{

if(info<(*current)->info)

Add(&(*current)->left, info);

else if(info>(*current)->info)

Add(&(*current)->right, info);

else

(*current)->count++;

}

else

{

*current=new TREE;

(*current)->info=info;

(*current)->left=NULL;

(*current)->right=NULL;

(*current)->count=1;

count++;

}

}

void AddLoop(int info)

{

if(root==NULL)

{

root=new TREE;

root->info=info;

root->right=NULL;

root->left=NULL;

root->count=1;

count++;

}

else

{

TREE *current=root;

TREE *parent;

while(current!=NULL)

{

parent=current;

if(info info)

current=current->left;

else if(info>current->info)

current=current->right;

else

{

current->count++;

current=NULL;

}

}

if(info info)

{

current=new TREE;

current->left=NULL;

current->right=NULL;

current->info=info;

current->count=1;

parent->left=current;

count++;

}

else if(info>parent->info)

{

current=new TREE;

current->left=NULL;

current->right=NULL;

current->info=info;

current->count=1;

parent->right=current;

count++;

}

}

}

void Changer(TREE **current, TREE **tmp)

{

if((*current)->right!=NULL)

Changer(&(*current)->right, &(*tmp));

else

{

(*tmp)->info=(*current)->info;

*tmp=*current;

*current=(*current)->left;

}

}

int Delete (TREE **current, int info)

{

int r=0;

if(*current!=NULL)

{

if(info<(*current)->info)

r=Delete(&(*current)->left, info);

else if(info>(*current)->info)

r=Delete(&(*current)->right, info);

else

{

TREE *tmp=*current;

if(tmp->right==NULL)

*current=tmp->left;

else if(tmp->left==NULL)

*current=tmp->right;

else

Changer(&(*current)->left, &tmp);

delete tmp;

count--;

r=1;

}

}

return r;

}

void ShowBackSymmetric(TREE *current, int l)

{

if(current!=NULL)

{

ShowBackSymmetric(current->right, l+1);

for(int i=0; i info << endl;

ShowBackSymmetric(current->left, l+1);

}

}

void Show(TREE *current)

{

if(current!=NULL)

{

Show(current->left);

cout << current->info << "(" << current->count << ")" << "";

Show(current->right);

}

}

void Clear(TREE **current)

{

if(*current!=NULL)

{

Clear(&(*current)->left);

Clear(&(*current)->right);

delete *current;

count--;

if(count==0)

*current=NULL;

}

}

int main()

{

setlocale(LC_ALL,"Russian");

int n, num;

char otv;

do

{

cout << endl << "1. Создать"

<< endl << "2. Добавить"

<< endl << "3. Добавить (цикл)"

<< endl << "4. Удалить"

<< endl << "5. Обратно-симметричный обход"

<< endl << "6. Вывод со счетчиком"

<< endl << "7. Очистить"

<< endl << "0. Выход"

<< endl << " = ";

cin >> otv;

switch(otv)

{

case '1':

cout << endl << "Кол-во элементов = ";

cin >> n;

for (int i=0; i > num;

Add(&root, num);

cout << endl << "Элемент добавлен" << endl;

break;

case '3':

cout << endl << "Введите элемент = ";

cin >> num;

AddLoop(num);

cout << endl << "Элемент добавлен" << endl;

break;

case '4':

if(root!=NULL)

{

cout << endl << "Удаляемый элемент = ";

cin >> num;

if(Delete(&root, num)==1)

cout << endl << "Элемент удален" << endl;

else

cout << endl << "Элемент не найден" << endl;

}

else

cout << endl << "Дерево пустое" << endl;

break;

case '5':

if(root!=NULL)

{

ShowBackSymmetric(root,0);

}

else

cout << endl << "Дерево пустое" << endl;

break;

case '6':

if(root!=NULL)

{

Show(root);

}

else

cout << endl << "Дерево пустое" << endl;

break;

case '7':

Clear(&root);

cout << endl << "Дерево очищено" << endl;

break;

case '0':

break;

default:

cout << endl << "Ошибка" << endl;

break;

}

}while(otv!='0');

cin. get();

}


переделать программу под задание(С++) #include #include using namespace std; struct TREE { int inf

👇
Открыть все ответы
Ответ:

var

 mas: array[0..11] of integer;

 a, c, b: integer;

begin

 for a := 0 to 9 do  

 begin

   mas[a] := random(-50, 50);//pascalabc.net позволяет задавать диапазон случайных чисел  

   write(mas[a], ' ');

   if mas[10] > mas[a] then begin mas[10] := mas[a]; b := a; end;

   if mas[11] < mas[a] then begin mas[11] := mas[a]; c := a; end;

 end;

 writeln;

 writeln('min[', b, '] = ', mas[10]);

 writeln('max[', c, '] = ', mas[11]);

 a := mas[b];

 mas[b] := mas[c];

 mas[c] := a;

 for a := 0 to 9 do write(mas[a], ' ');

end.


Яв 9 классе сделайте как в 9выведите max и min значения массива и поменяет их местамия пыталась но т
4,8(65 оценок)
Ответ:
dovlarisa
dovlarisa
18.10.2020

1 - не сделаю. Тк нет 121 стр...

Номер 2.

          10,2        10,8     -10,2      -10,8

Round(x) 10            11          -10          -11

Int(x)         10          10           -10         -10

Frac(x)      2            8             2            8

3.

program S;

var a, b: real;

begin

   write('a: ');

   readln(a);

   write('b: ');

   readln(b);

   

   writeln(a*b);

end.

4. Думаю сам справишься)))0)

Объяснение:

2. Думаю в объяснении не нуждается. В задании и так написано, что происходит)))

3. Создали переменные, запросили значения, вывели произведение.

4,5(36 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ