snezhkabo00
30.06.2020 04:28

Объяснить принцип работ следующих программ (записать, что происходит в каждой сточке программы): 1)
program n22;
var a,b:integer;
begin
writeln('введите целое число a');
readln(a);
writeln('введите целое число b');
readln(b);
writeln ('a mod b = ',a mod b);
writeln ('a div b = ',a div b);
end.

2)
program n_s;
var a, b, c: integer;
p, s: real;
begin
writeln('Вычисление площади треугольника по трем сторонам');
write('введите значения a, b, c');
readln(a, b, c);
p:= (a+b+c)/2;
s:= sqrt(p*(p-a)*(p-b)*(p-c));
writeln ('s=', s:2:1);
end.

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
katyavoloshina1
29.12.2020 08:34

#include <iostream>

#include <cmath>

#include <vector>

using namespace std;

int main() {

vector<float> coordinates;

string a;

getline(cin, a);

string buffer;

for(int i = 0; i<a.length(); ++i) {

 if(a[i]!=' ') {

  buffer+=a[i];

 } if(a[i]==' '||i==a.length()-1) {

  if(buffer[buffer.length()-1]=='.') {

   buffer+="0";

  }  

  float num = stof(buffer);

  coordinates.push_back(num);

  buffer = "";

 }

}

if(coordinates.size()!=4) {

 cout << "wrong data. example: 1.1 2.2 3.3 4.4";

}

float result;

int temp1, temp2, temp3, temp4;

temp1 = coordinates[0]-coordinates[2];

temp2 = coordinates[1]-coordinates[3];

temp1 = temp1 * temp1;

temp2 = temp2 * temp2;

temp3 = temp1 + temp2;

result = sqrt(temp3);

cout << result;

}

0,0(0 оценок)
Ответ:
lilikykytik21
28.02.2022 22:26

#include <iostream>

int main() {

const int SIZE = 10;

bool isSence = false;

int sum = 0;

int count = 0;

int arr[SIZE];

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

{

 arr[i] = rand() % 20 - 10; // "рандомно" заполняем массив от -10 до 10

 std::cout << arr[i] << "\t"; // выводим массив в консоль

 if (arr[i] >= 0)

  isSence = true;

}

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

{

 if ((isSence) && (arr[i] > 0))

  sum += arr[i]; //sum = sum + arr[i];

  count++;

}

if (isSence)

 std::cout << "\nсреднее арифметическое положительных чисел = " << double(sum) / count << std::endl; // явное приведение типов

else

 std::cout << "\nВ массиве нету положительных чисел или нету нулей и/или отрицательных чисел" << std::endl;

return 0;

}

0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота