# # Код на ruby 2.2.3p173
max = 0
max_last = 0
min = 1000
min_last = 1000
n = 0
begin
max_last = max
min_last = min
File.open("input.txt", "r") do |infile|
line = infile.gets.strip
p line
n = line.to_i if n == 0
while (line = infile.gets)
p line
number = line.strip.to_i
max = number if max == 0 or number == max + 1
min = number if min == 1000 or number == min - 1
p [min, max]
end
end
end until (max == max_last and max < n) or (min > 0 and min == min_last) or (min == 0 and max == n)
p max + 1 if max == max_last and max < n
p min - 1 if min > 0 and min == min_last
p "error" if min == 0 and max == n
Записи на бумаге
запись на жесткий диск
вроде так
Длина цепочки равна 1сантиметру
#include <iostream>
#include <math.h>
using namespace std;
int main() {
cout.precision(10);
double x, y, z;
cin >> x >> y >> z;
if (x>=0) cout << sqrt(x) << " ";
if (y>=0) cout << sqrt(y) << " ";
if (z>=0) cout << sqrt(z);
return 0;
}