Переведите с паскаля на python var k, max, countA: integer;
c: char;
f: text;
begin
assign(f,'C:\24.txt');
reset(f);
k := 0;
max := 0;
countA := 0;
while not Eof(f) do begin
read(f, c);
if (c = 'E') then begin
if countA > 2 then begin
if k > max then max := k;
end;
k := 0;
countA := 0;
end
else begin
if c = 'A' then countA := countA + 1;
k := k + 1;
end;
end;
if k > max then
max := k;
writeln(max);
end.
c = int(input('Enter 2 to start'))
while c != 1:
import math as m
a = int(input('Write a: '))
b = int(input('Write b: '))
c = int(input('Write c: '))
D = (b ** 2) - (4 * a * c)
print ('D =',D)
if D > 0:
print('D > 0')
x = (-b + (m.sqrt(D))) / (2 * a)
x1 = (-b - (m.sqrt(D))) / (2 * a)
print ('x1 =',x)
print ('x2 =',x1)
elif D == 0:
print('D = 0')
x = -b / (2 * a)
print ('x =',x)
else:
print('D < 0')
print ('No roots')
c = int(input('Enter 1 to quit or 2 to repeat'))
#include <iostream>
using namespace std;
int main () {
int n;
cin >> n;
if (n==0) {
cout << "0 0" << endl << 1 << endl << 1 << endl;
return 0;
}
int mx=0; int mn=10; int mxi=10; int mnk=0; int ind=0;
while (n>0) {
int c=n%10;
n/=10;
if (c>=mx) {
mx=c;
mxi=ind;
}
if (c<mn) {
mn=c;
mnk=1;
} else if (c==mn) {
++mnk;
++ind;
}
}
cout << mx << " " << mn << endl << (ind - mxi) << endl << mnk << endl;
return 0;
}
Объяснение: