program raf105;
const
n = 10;
var
x: array[1..n] of integer;
i: integer;
a,b,c: boolean;
begin
a:= True;
writeln('Заполните массив из ',n,' чисел');
for i:=1 to n do
begin
readln(x[i]);
a:= (x[i] = 0) and a;
b:= ( not(c) and (x[i] > 0) ) or b;
c:= ( not(b) and (x[i] < 0) ) or c;
end;
if a
then writeln('Все числа равны нулю');
if b
then writeln('Первое ненулевое число - положительное');
if c
then writeln('Первое ненулевое число - отрицательное');
end.
PascalABC 3.4.2
#include <iostream>
#include <vector>
using namespace std;
int fibo(int n, int &cnt){
cnt++;
if(n == 1 || n == 2)
return 1;
return fibo(n-1,cnt) + fibo(n-2,cnt);
}
void solve1(){
int k = 5;
while(k--){
int n,ans = 0;
cin >> n;
cout << fibo(n,ans) << " " << ans << "\n";
}
}
void solve2(){
const int INF = 1e9 + 7;
int n, mx1 = -INF, mx2 = -INF;
cin >> n;
vector<int> a(n);
for(auto &i : a) cin >> i;
for(auto &i : a){
if(i > mx1){
mx2 = mx1;
mx1 = i;
}
else if(i > mx2)
mx2 = i;
}
cout << mx2 << " " << mx1;
}