Var St: string; z:string[10]; x:string[2]; i,j,k,m: integer; //новые переменные Begin Write('введите строку текста - St'); Readln(St); k:=0; //обнуляем на всякий случай z:='0123456789'; i:=1; for j:=1 to length(St) do //начало begin; for m:=1 to 10 do if St[j]=z[m] then inc(k); end; if k=0 then begin; writeln('в тексте нет цифр'); exit; end; //конец while i<=length(st)-1 do begin x:=copy(st,I,2); if (x[1]=x[2]) and (pos(x[1],z)<>0) then begin delete(st,i,2); insert('две',st,i); i:=i+1; end; i:=i+1; end; writeln('преобразованная строка ', st); End.
z:string[10];
x:string[2];
i,j,k,m: integer; //новые переменные
Begin
Write('введите строку текста - St');
Readln(St);
k:=0; //обнуляем на всякий случай
z:='0123456789';
i:=1;
for j:=1 to length(St) do //начало
begin;
for m:=1 to 10 do
if St[j]=z[m] then inc(k);
end;
if k=0 then
begin;
writeln('в тексте нет цифр');
exit;
end; //конец
while i<=length(st)-1 do
begin
x:=copy(st,I,2);
if (x[1]=x[2]) and (pos(x[1],z)<>0) then
begin
delete(st,i,2);
insert('две',st,i);
i:=i+1;
end;
i:=i+1;
end;
writeln('преобразованная строка ', st);
End.
#include <iostream>
using namespace std;
int main() {
setlocale(LC_ALL, "");
int N = 10;
int max = -9999999;
int sum = 0;
int choise = 0;
int arr[N] = {0};
cout << "Введите 10 значений: ";
for(int i = 0; i<N; ++i) {
cin >> arr[i];
}
cout << "Введите действие (1 - +, 2 - макс. значение, 3 - колво отр. значений)";
cin >> choise;
if(choise==1) {
for(int i = 0; i<N; ++i) {
sum+=arr[i];
}
cout << endl << "Сумма: " << sum;
}
if(choise==2) {
for(int i = 0; i<N; ++i) {
if(arr[i]>max) {
max = arr[i];
}
}
cout << endl << "Макс. знач: " << max;
}
if(choise==3) {
for(int i = 0; i<N; ++i) {
if(arr[i]<0) {
++sum;
}
}
cout << "Колво отр. знач: " << sum;
}
if(choise!=1&&choise!=2&&choise!=3) {
cout << "Введите корректное значение.";
}
return 0;
}