#include<iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
int main(){
system("chcp 1251 > null");
int n = 0;
cout << "Задача 1.\n\tВведіть n: ";
cin >> n;
int i = 1;
while(i<=n){
if(i%7==0) cout << i;
i++;
}
cout << "\n\n";
int a,b;
cout << "Задача 2.\n\tВведіть перше число діапазону: ";
cin >> a;
cout <<"\n\tВведіть друге число діапазону: ";
cin >> b;
double sum = 0;
double sr = 0;
int index = 0;
i = a;
while(i<=b){
sum = sum+i;
index++;
i++;
}
sr = sum / index;
cout << "\n\nСума: " << sum << "\nСереднє арифметичне: " << sr;
int x = 0;
int y = 0;
cout << "\n\nЗадача 3.\n\tВведіть x: ";
cin >> x;
cout << "\n\tВведіть y: ";
cin >> y;
cout << "Результат" << powl(x,y);
}
Вот, переделал задачу, под while. И кстати, отблагодарить ещё можно нажав кнопочку "Лучший ответ" ;-)
===== PascalABC.NET ====
begin
var a := ArrRandom(25, 20, 100);
a.Println.SortedDescending.Println
end.
===== Free Pascal =====
const
n = 25;
var
a: array[1..n] of integer;
i, j, t: integer;
begin
randomize;
for i := 1 to n do
begin
a[i] := random(81) + 20;
write(a[i], ' ')
end;
writeln;
// пузырьковая сортировка по убыванию
for i := n - 1 downto 1 do
for j := 1 to i do
if a[j] < a[j + 1] then
begin
t := a[j];
a[j] := a[j + 1];
a[j + 1] := t
end;
// вывод результатов
for i := 1 to n do
write(a[i], ' ');
end.