int main() { int xm = 21, ym = 11; double ret[xm][ym]; for (int i = 0; i < xm; i++) { for (int j = 0; j < ym; j++) { ret[i][j] = i + j; cout << ret[i][j] << ' '; } cout << endl; } return 0; }
mvinogradov6
23.07.2022
1. "Школьное" решение
// PascalABC.NET 3.0, сборка 1073 const sb='bcdfgjklmnpqrstvwxz'; s='Computer programming is a process of computer programs creation'; var i,n:integer; s1,sn,t:string; begin i:=1; while s[i]<>' ' do Inc(i); s1:=Copy(s,1,i-1); n:=Length(s); i:=n; while s[i]<>' ' do Dec(i); sn:=Copy(s,i+1,n-i); t:=''; for i:=1 to Length(s1) do if Pos(s1[i],sb)>0 then t:=t+s1[i]; s1:=t; t:=''; for i:=1 to Length(sn) do if Pos(sn[i],sb)>0 then t:=t+sn[i]; sn:=t; t:=''; for i:=1 to Length(s1) do if Pos(s1[i],sn)>0 then if Pos(s1[i],t)=0 then t:=t+s1[i]; for i:=1 to Length(t) do Write(t[i],' '); Writeln end.
Тестовый прогон: t r
2. "Нормальное" решение
// PascalABC.NET 3.0, сборка 1073 const sb='bcdfgjklmnpqrstvwxz'; s='Computer programming is a process of computer programs creation'; begin var a:=s.ToWords(' '); a[0].Intersect(a[a.Length-1]).Where(x->Pos(x,sb)>0).Println(',') end.
Тестовый прогон: t,r
krisrespect
23.07.2022
Программа в системе PascalABC.Net (время выполнения около 2с) var n1,n2,n3:int64;
function IsPrime(n:Int64):Boolean; var p:Int64; found:Boolean; begin case n of 1:Isprime:=False; 2:IsPrime:=True; else begin found:= (n Mod 2 = 0); p:=3; while (not found) and (sqr(p)<=n) do begin found:=(n Mod p = 0); p:=p+2 end; IsPrime:=(not found) or (p = 2) end end end;
procedure Fib(); begin n3:=n1+n2; n1:=n2; n2:=n3 end;
var i,k:integer; begin n1:=0; n2:=1; k:=0; Writeln('Простые среди первых 45 чисел Фибоначчи'); for i:=3 to 45 do begin Fib; if IsPrime(n3) then begin Write(n3,' '); Inc(k) end end; Writeln(#13#10,'Найдено простых чисел: ',k) end.
Результат выполнения программы: Простые среди первых 45 чисел Фибоначчи 2 3 5 13 89 233 1597 28657 514229 433494437 Найдено простых чисел: 10
#include <iostream>
using namespace std;
int main()
{
int xm = 21, ym = 11;
double ret[xm][ym];
for (int i = 0; i < xm; i++) {
for (int j = 0; j < ym; j++) {
ret[i][j] = i + j;
cout << ret[i][j] << ' ';
}
cout << endl;
}
return 0;
}