Ифодалар
Натижа
‘True1’<’True2’
True
‘Mother’>’MOTHER’
True
‘Geografiya’>’Geologiya’
False
‘Cat’=’Cat’
True
‘uzunlik’>’balandlik’
True
Yuqorida keltirilgan funksiya va protseduralardan dasturlarda qo‘llashga miollar
keltiramiz:
1-misol.
uses crt;
var
s1,s2,s3,s4,s5:string;
begin clrscr;
s1:='satriy';
s2:='kattaliklar';
s3:=concat(s1,' ',s2);
writeln(s3);
s4:=s1+' '+s2;
writeln(s4);
writeln(length(s3));
s5:=copy(s3,length(s3)-2,3);
writeln(s5);
end.
Dastur natijasi:
2-misol.
uses crt;
var
s1,s2,s3,s4,s5:string;
i:integer;
begin clrscr;
s1:='SAMARQAND';
i:=pos('QAND',s1);
writeln(i);
s2:='biologiya';
s3:='fizika';
delete(s2,1,2);
delete(s3,5,2);
insert(s2,s3,5);
writeln(s3);
readln;
end.
dastur natijasi:
Kiritilgan ixtiyoriy jumla tarkibidagi “A” belgisini “O” belgisiga almashtirish chop etuvchi
dastur tuzing.
1-usul
2-usul
PROGRAM sim1;
VAR jumla:string;i,d: INTEGER;
PROGRAM sim1;
VAR jumla:string;i,d: INTEGER;
SIM:STRING;
BEGIN
read(Jumla);d:=length(jumla);
writeln(d);
FOR I:=1 TO D DO
BEGIN
IF COPY(JUMLA,I,1)='A'
THEN JUMLA[I]:='O';
END;
WRITELN(JUMLA); readln;
END.
SIM:STRING;
BEGIN
read(Jumla);d:=ord(jumla[0]);
writeln(d);
FOR I:=1 TO D DO
BEGIN
IF JUMLA[I]='A'
THEN JUMLA[I]:='O';
END;
WRITELN(JUMLA);
readln;
END.
Burchak qiymati gradus o’lchovida kiritilgan holat uchun sinus, kosinus, tangens
funksiyalari qiymatini mos belgini tanlash yo’li bilan hisoblovchi dastur tuzing.
PROGRAM char1;
uses crt;
VAR sim:char; i,grad:INTEGER;javob,radian:real; label 15,20;
BEGIN
writeln('burchak qiymatini gradus o''lchovida kiriting');
readln(grad); radian:=(pi*grad)/180;
writeln('sinus ', grad,' ni hisoblash uchun ''s'' tugmasini tanlang');
writeln('kosinus ', grad,' ni hisoblash uchun ''c'' tugmasini tanlang');
writeln('tangens ', grad,' ni hisoblash uchun ''t'' tugmasini tanlang');
sim:=readkey;
case sim of
's': javob:=sin(radian);
'c': javob:=cos(radian);
't': if cos(radian)=0 then goto 15 else javob:=sin(radian)/cos(radian);
end;
WRITELN(javob:5:2);goto 20;
15:writeln ('qiymatimavjud emas');
20: readln;
END.
Tarkibida raqamlar bo'lgan s1-satriy kattalikning barcha raqamlridan yangi s2 –satiy
kattalik yaratuvchi dastur tuzing.
Program Satriy_kattaliklar;
Var s1, s2: string; i: byte;
begin
writeln('Tarkibida paqamlar bo''lgan satriy kattalikni kiriting');
readln(s1);
s2:='';
for i:=1 to length(s1) do
if (s1[i]>='0') and (s1[i]<='9')
then s2:=s2+s1[i];
writeln('natija ',s2);
end.
Dasturni quyidagi qiymat uchun tekshirb to’g’ri tuzilganiga ishinch hosil qiling:
S1:=’Balandligi 375 m bo’’lgan poytaxtdagi teleminora’;
Natija: 375
Masala
S-satriy miqdorning boshida joylashgan barcha bo’shliq belgilarini o’chiruvchi dastur
tuzing.
Program Sinov1;
Var s: string[80];
Begin
writeln(‘Boshida bir necha bo’’shliq belgisi qatnashgan s-satriy miqdor ni kirining’);
readln(s);
while (pos(‘ ‘,s)=1) and (length(s)>0) do
delete(s,1,1);
write(Natija’,s);
end.
Do'stlaringiz bilan baham: |