ответ: добавил <limits.h>, хотя на Visual С++ у меня без этого работало, и условие && a != 0 (что то не везёт мне с этой задачей)
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
int a, i, imin, amin;
setlocale(LC_ALL, "Russian");
cout << "Введите числа: ";
i = 0;
amin = INT_MAX;
imin = 0;
do {
i++;
cin >> a;
if (a < amin && a != 0) {
amin = a;
imin = i;
}
} while (a != 0);
if (i > 1)
cout << "\n№ минимального элемента = " << imin << endl;
else
cout << "\nПоследовательность пустая" << endl;
getchar();
}
1)
Program Pr1;
uses crt;
var stroka:string;
a:integer;
Begin
clrscr;
writeln('Vvedite chislo');
readln(stroka);
a:=length(stroka);
a:=Trunc(a/2)+1;
writeln(a);
end.
2)
Program Pr1;
uses crt;
var stroka:string;
a,i:integer;
Begin
clrscr;
writeln('Vvedite stroku');
readln(stroka);
a:=0;
for i:=1 to length(stroka) do if stroka[i]=',' then a:=a+1;
writeln(a);
end.
3)
Program Pr1;
uses crt;
var stroka:string;
a,i:integer;
c:char;
Begin
clrscr;
writeln('Vvedite stroku');
readln(stroka);
writeln('Vvedite simvol');
readln(c);
a:=0;
for i:=1 to length(stroka) do if stroka[i]=c then break
else a:=a+1;
writeln(a);
end.
4)
Program Pr1;
uses crt;
var stroka:string;
procedure word9(strokk:string);
var i:integer;
tmp:string;
begin
for i:=1 to length(stroka) do if (stroka[i]=' ') or (stroka[i]='.') then begin
writeln(tmp,' ',length(tmp));
tmp:='';
end
else tmp:=tmp+stroka[i];
end;
Begin
clrscr;
writeln('Vvedite predlogenie');
readln(stroka);
word9(stroka);
end.
6)
Program Pr1;
uses crt;
var stroka:string;
a,i:integer;
Begin
clrscr;
a:=0;
readln(stroka);
for i:=1 to length(stroka) do if stroka[i] in ['A'..'z'] then a:=a+1;
writeln(a);
end.
7)
Program Pr1;
uses crt;
var stroka:string;
procedure word8(strokk:string);
var i:integer;
begin
for i:=1 to length(strokk) do if strokk[i]=' ' then strokk[i]:='_';
writeln(strokk);
end;
Begin
clrscr;
readln(stroka);
word8(stroka);
end.
8)
Program Pr1;
uses crt;
var stroka,tmp:string;
i,a:integer;
Begin
clrscr;
readln(stroka);
tmp:='';
a:=0;
for i:=1 to length(stroka) do if (stroka[i]=' ') or (stroka[i]='.') then begin
a:=a+1;
writeln(tmp,' ',a);
tmp:='';
end
else tmp:=tmp+stroka[i];
end.
9)
Program Pr1;
uses crt;
var stroka:string;
procedure word7(strokk:string);
var c:char;
i,a:integer;
begin
a:=0;
for i:=1 to length(strokk) div 2 do begin
c:=strokk[i];
strokk[i]:=strokk[length(strokk)-a];
strokk[length(strokk)-a]:=c;
a:=a+1;
end;
writeln();
for i:=1 to length(strokk) do write(strokk[i]);
end;
begin
clrscr;
readln(stroka);
word7(stroka);
end.
10)
Program Pr1;
uses crt;
var stroka,tmp:string;
i,b:integer;
begin
clrscr;
readln(stroka);
stroka[1]:='*';
for i:=1 to length(stroka) do if stroka[i]=' ' then for b:=i to length(stroka) do if stroka[b] in ['A'..'я'] then begin
stroka[b]:='*';
break;
end;
writeln(stroka);
end.
11)
Program Pr1;
uses crt;
var stroka:string;
i,b:integer;
begin
clrscr;
readln(stroka);
b:=0;
for i:=1 to length(stroka) do if (stroka[i]='А') or (stroka[i]='а') or (stroka[i]='О') or (stroka[i]='о') then b:=b+1;
writeln(b);
end.