Pascal: var n,a,s:longint; begin repeat write ('N = '); readln(n); until n in [10..99]; write ('A = '); readln(a); s:=0; while n<>0 do begin s:=s+n mod 10; n:=n div 10; end; if s>a then writeln ('YES') else writeln ('NO'); readln; end.
C++: #include <iostream> using namespace std;
int main() { int a,n,s = 0; do { cout <<"N = "; cin >>n; } while (n<10 || n>99); cout <<"A = "; cin >>a; while (n!=0) { s+=n%10; n/=10; } if (s>a) cout <<"YES" <<endl; else cout <<"NO" <<endl; return 0; }
ktatarinova
04.06.2022
// PascalABC.NET 3.1, сборка 1179 от 29.02.2016 procedure GetProdNeg(a:array of integer; var p:real); // произведение отрицательных элементов begin p:=a.Where(x->x<0).Aggregate(1.0,(p,e)->p*e) end;
function IsPrime(n:integer):boolean:= Range(2,Round(sqrt(n))).All(i->n mod i<>0);
procedure ArrPrime(n:integer; var a:array of integer); // массив простых чисел не больших n begin a:=Range(2,n).Where(i->IsPrime(i)).ToArray end;
begin var n:=ReadInteger('n='); var a:=ArrRandom(n,-50,50); a.Println; var r:real; GetProdNeg(a,r); Writeln('Произведение ',r); n:=ReadInteger('n='); var b:array of integer; ArrPrime(n,b); b.Println end.
var n,a,s:longint;
begin
repeat
write ('N = ');
readln(n);
until n in [10..99];
write ('A = ');
readln(a);
s:=0;
while n<>0 do
begin
s:=s+n mod 10;
n:=n div 10;
end;
if s>a then writeln ('YES') else writeln ('NO');
readln;
end.
C++:
#include <iostream>
using namespace std;
int main()
{
int a,n,s = 0;
do
{
cout <<"N = ";
cin >>n;
}
while (n<10 || n>99);
cout <<"A = ";
cin >>a;
while (n!=0)
{
s+=n%10;
n/=10;
}
if (s>a)
cout <<"YES" <<endl;
else cout <<"NO" <<endl;
return 0;
}