var
x, y: integer;
n: integer;
sum: integer;
mindif: integer;
f: text;
begin
assign(f,'C:\27-A.txt');
reset(f);
readln(f, n);
sum := 0;
mindif := 20001;
while not eof(f) do begin
readln(f, x, y);
if x > y then
sum := sum + x
else
sum := sum + y;
if (abs(x - y) < mindif) and (abs(x-y) mod 3 <> 0) then mindif := abs(x-y);
end;
if sum mod 3 <> 0 then
writeln(sum)
writeln(sum - mindif);
end.
Объяснение:
var
x, y: integer;
n: integer;
sum: integer;
mindif: integer;
f: text;
begin
assign(f,'C:\27-A.txt');
reset(f);
readln(f, n);
sum := 0;
mindif := 20001;
while not eof(f) do begin
readln(f, x, y);
if x > y then
sum := sum + x
else
sum := sum + y;
if (abs(x - y) < mindif) and (abs(x-y) mod 3 <> 0) then mindif := abs(x-y);
end;
if sum mod 3 <> 0 then
writeln(sum)
else
writeln(sum - mindif);
end.
Объяснение:
#include <cmath>
using namespace std;
void main()
{
int n,sum=0;
float y,k=0;
cin >> n;
int *mass = new int[n];
for (int i = 0;i < n;++i)
{
cin >> mass[i];
}
for (int i = 0;i < n;++i)
{
if (mass[i] >0 )
{
k++;
y=pow(mass[i],2);
cout<<y;
sum+=mas[i]
}
}
system("pause");
}
2)#include <iostream>
#include <cmath>
using namespace std;
void main()
{
int s,p,r,day=0;
cin >> s>>p>>r;
float km=s;
while(r>km)
{
km+=km*p/100;
day++;
}
cout << " km = " << km << " day = " << day << endl;
system ("pause");
}