Воздух5
14.12.2022 17:40

Слабые стороны цифровизаций​

Нажмите на рекламу ниже и сразу увидите ответ
↓
Популярные вопросы:
Ответ:
бринн
14.05.2023 14:04

#include<iostream>

#include<windows.h>  

using namespace std;

 

struct Sponsor

{

char name[32];

char surname[32];

double sum;

};

 

Sponsor* AddStruct(Sponsor* Obj, const int amount);

void setData(Sponsor* Obj, const int amount);

void showData(const Sponsor* Obj, const int amount);

 

int main()

{

setlocale(LC_ALL, "rus");

 

Sponsor* OurSponsors = 0;

int sponsorAmount = 0;

int YesOrNot = 0; //  продолжить или остановить ввод данных

 

do

{

OurSponsors = AddStruct(OurSponsors, sponsorAmount);

setData(OurSponsors, sponsorAmount);

 

sponsorAmount++;

 

cout << "Продолжить ввод данных (1 - да, 0 - нет): ";

cin >> YesOrNot;

cin.get();

} while (YesOrNot != 0);

 

showData(OurSponsors, sponsorAmount);

 

delete[] OurSponsors;

return 0;

}

 

Sponsor* AddStruct(Sponsor* Obj, const int amount)

{

if (amount == 0)

{  

Obj = new Sponsor[amount + 1]; // выделение памяти для первой структуры

}

else

{

Sponsor* tempObj = new Sponsor[amount + 1];

 

for (int i = 0; i < amount; i++)

{

tempObj[i] = Obj[i]; // копируем во временный объект

}

delete [] Obj;

 

Obj = tempObj;  

}  

return Obj;

}

//

void setData(Sponsor* Obj, const int amount)

{

cout << "Фамилия: ";

cin.getline(Obj[amount].surname, 32);

cout << "Имя: ";

cin.getline(Obj[amount].name, 32);

cout << "Сумма пожертвования: ";

cin >> Obj[amount].sum;

cin.get();  

cout << endl;  

}

//

void showData(const Sponsor* Obj, const int amount)

{

system("cls");

cout << "№  " << "Фамилия\t" << "Имя\t" << "Сумма\t" << endl;

cout << "" << endl;

for (int i = 0; i < amount; i++)

{  

cout << i + 1 << "  " << Obj[i].surname << '\t' << Obj[i].name << '\t' << Obj[i].sum << endl;

}

}

Объяснение:

0,0(0 оценок)
Ответ:
вованчик3
22.12.2022 16:34
Var   
i,su1,su2:integer;
a:array[1..10] of integer; 
 input,output:text;
begin 
 assign(input,'input.txt'); 
 assign(output,'output.txt');
 reset(input); 
 rewrite(output); 
for i:=1 to 10 do     
 read(input,a[i]); 
for i:=1 to 10 do 
    begin       
       if a[i]>0         
          then           
             inc(su1,a[i])
          else         
             inc(su2,a[i]);   
    end;   
writeln(output,'Сумма положительных:',su1); 
write(output,'Сумма отрицательных:',su2);
close(input);
close(output);
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота