#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
int n, k, chastnoe, ostatok;
cout << "Введите делимое N = ";
cin >> n;
cout << "Введите делитель K = ";
cin >> k;
if (k != 0)
{
int tmp = n;
chastnoe = ostatok = 0;
while (tmp >= k)
{
tmp -= k;
chastnoe++;
}
ostatok = tmp;
}
cout << "Частное от деления: " << chastnoe << endl;
cout << "Остаток от деления: " << ostatok << endl;
return 0;
}
Объяснение:
i,p:integer;
n:real;
m:longint;
begin
n:=0;
p:=0;
m:=1;
write ('Массив: ');
for i:=1 to 20 do
begin
a[i]:=random(101)-50;
write (a[i],' ');
end;
for i:=1 to 20 do
begin
n:=n+a[i];
end;
n:=n/20;
writeln;
writeln;
write ('Среднее арифметическое = ',n);
for i:=1 to 19 do
begin
if a[20]<>a[i] then p:=p+1;
end;
writeln;
write ('Кол-во чисел отличных от последнего в массиве = ',p);
for i:=1 to 20 do
begin
if a[i]<0 then m:=m*a[i];
end;
writeln;
write ('Произведение отрицательных чисел массива = ',m);
end.