#include <stdlib.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
const int n = 30;
double a[n];
double max, min;
srand(time(0));
for (int i = 0; i < n; i++) {
a[i]=-20 + (51.0 / RAND_MAX) * rand();
cout << fixed << setw (7) << setprecision (2) << a[i];
}
cout <<"\n";
max = a[0]+a[n-1];
min = a[0]*a[n/2];
for (int i = 1; i<n/2; i++){
if (a[i]+a[n-i-1] > max) max = a[i]+a[n-i-1];
if (a[i]*a[n/2+i] < min) min = a[i]*a[n/2+i];
}
cout << "max = " << max << "\n";
cout << "min = " << min << "\n";
return 0;
}
Пример (для n=10):
<span>-19.29 30.99 -15.37 26.41 3.65 13.45 29.28 4.28 30.51 -10.36
</span><span>max = 61.50
min = -259.43</span>
Cls
input n
dim a(n)
for i=1 to n
input a(i)
next i
for i=1 to n
for j=1 to n
if a(i)<a(j) then swap a(i),a(j)
next j
next i
for i=1 to n
print a(i);
next i
744 бита (.................)
#include <iostream>
using namespace std;
int main () {
int a,b;
cout << "Введите два числа: " << endl;
cin >> a >> b;
if(a > 0 || b > 0)
cout << max(a,b) * 2;
else
cout << "Некорректный ввод." << endl;
}
1.
var a: real;
x,y: integer;
begin
readln(x,a,y);
writeln('1 kg konfet stoit ', a/x:1:2);
writeln(y,' kg konfet stoyat ', a/x*y:1:2);
readln;
end.
2.
var a,s,p: integer;
begin
readln(a);
s:=a mod 10 + a div 10;
p:=(a mod 10)*(a div 10);
writeln(s);
writeln(p);
readln;
end.
3.
var a,b: integer;
begin
readln(a);
b:=(a mod 10)*10+(a div 10);
writeln(b);
readln;
end.
Это если без циклов.