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.
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.
Поделитесь своими знаниями, ответьте на вопрос:
Опять не школьный вопрос но кто шарит , напишите в чём ошибка. пишет на 32 строке ошибка was not declared in this scope #include #include using namespace std; int main(int sys) { cout < < "if you would midle write-1, if place of circle-2" < < endl; cin < < sys; if(sys == 1) { float a, b, c, d, e, sum, mid, pi=3.14, g, r; cout < < "input first midle" < < endl; cin > > a; cout < < "inpur second midle" < < endl; cin > > b; cout < < "input third midle" < < endl; cin > > c; cout < < "input thord midle" < < endl; cin > > d; cout < < "input fived midle" < < endl; cin > > e; sum = a + b + c + d + e; mid = sum / 5; cout < < "your midle: "; cout < < mid; } else{ if(sys == 2) { cout < < "this is the circle area formula s=pi*r^2" < < endl; cout < < "input radius(r)" < < endl; cin > > r; cout < < pi * r * r; } } return 0; }
Во-первых в начале НЕ сin << sys, а сin >> s;
Во-вторых ты объявил/а все переменные в первом ифе, а значит в других функциях они уже не видны, поэтому стоит их объявить глобально
В-третьих переменная g не используется, поэтому можно ее и не объявлять
Вот код:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int sys;
float a, b, c, d, e, sum, mid, pi=3.14, r;
cout << "if you would midle write-1, if place of circle-2" << endl;
cin >> sys;
if(sys == 1) {
cout << "input first midle" << endl;
cin >> a;
cout << "inpur second midle" << endl;
cin >> b;
cout << "input third midle" << endl;
cin >> c;
cout << "input thord midle" << endl;
cin >> d;
cout << "input fived midle" << endl;
cin >> e;
sum = a + b + c + d + e;
mid = sum / 5;
cout << "your midle: ";
cout << mid;
}
else{
if(sys == 2) {
cout << "this is the circle area formula S=pi*r^2" << endl;
cout << "input radius(r)" << endl;
cin >> r;
cout << pi * r * r;
}
}
return 0;
}