// PascalABC.NET 3.1, сборка 1204 от 24.03.2016 begin var F,G:file of integer; Assign(F,'FFile.dat'); Rewrite(F); for var i:=1 to 30 do Write(F,Random(-20,20)); // Файл F создан и заполнен Assign(G,'GFile.dat'); Rewrite(G); F.Seek(0); var e:integer; Print('F:'); while not F.Eof do begin Read(F,e); Print(e); if e>0 then Write(G,e) end; F.Seek(0); while not F.Eof do begin Read(F,e); if e<0 then Write(G,e) end; F.Seek(0); while not F.Eof do begin Read(F,e); if e=0 then Write(G,e) end; F.Close; Writeln; Print('G:'); G.Seek(0); while not G.Eof do begin Read(G,e); Print(e) end; G.Close end.
Данное решение неоптимально по времени, поскольку файл читается трижды. Можно сделать иной вариант, читая данные за один проход и помещая в две вс структуры памяти отрицательные и нулевые элементы.
// PascalABC.NET 3.1, сборка 1204 от 24.03.2016 begin var F,G:file of integer; Assign(F,'FFile.dat'); Rewrite(F); for var i:=1 to 30 do Write(F,Random(-20,20)); // Файл F создан и заполнен Assign(G,'GFile.dat'); Rewrite(G); var n:=F.FileSize; var neg,zer:array of integer; SetLength(neg,n); SetLength(zer,n); F.Seek(0); var e:integer; var ineg:=0; var izer:=0; Print('F:'); while not F.Eof do begin Read(F,e); Print(e); if e>0 then Write(G,e) else if e<0 then begin neg[ineg]:=e; Inc(ineg) end else begin zer[izer]:=e; Inc(izer) end end; F.Close; Writeln; SetLength(neg,ineg); foreach e in neg do Write(G,e); SetLength(zer,izer); foreach e in zer do Write(G,e); Print('G:'); G.Seek(0); while not G.Eof do begin Read(G,e); Print(e) end; G.Close end.
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int a, b, c; cin>>a>>b>>c; if ((a + b < c) || (a + c < b) || (b + c < a)) { cout<<"Не треугольник"; return 0; } if ((a * a + b * b == c * c) || (a * a + c * c == b * b)|| (c * c + b * b == a * a)) { cout<<"Прямоугольный"; return 0; } if ((a * a + b * b > c * c) || (a * a + c * c > b * b)|| (c * c + b * b > a * a)) cout<<"Остроугольный"; else cout<<"Тупоугольный"; }
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку