Fayllar bilan ishlash mavzusiga oid dasturlar tuzish
1.Sinfdoshlaringizning familiya va ismlaridan tashkil topgan «SINF.TXT» nomli matnli fayl hosil qiluvchi dastur tuzing.
Program Sinf;
Uses crt;
var f : Text; i : Integer; ism : String;
Begin
Assign(fio, 'c:sinf.txt'); Rewrite(f); For i:=l to 7 Do begin
WriteLn(I,'-ovquvchining familiyasi va ismini kiriting='); ReadLn(ism);
Writeln(f,ism);end;
Close(fio); readln;
End.
2.«sinf.txt» faylida berilgan 9-sinf o'quvchilarning familiyalari ichidan «M» harfi bilan boshlanadiganlarini ekranga chiqaruvchi dastur tuzing.
Program misol_2;
Uses crt;
var hafta: array[1..7]of string; f : Text; s: string ; I: integer;
Begin clrscr
Assign(f, 'c:sinf.txt'); Reset(f);
For i:=1 to 7 do begin
Readln(f,s); if s[1]= ‘M’ then Writeln(s); end;
Close(f); readln;
End.
3.«sinf.txt» faylida berilgan 9-sinf o'quvchilarning familiyalari ichidan «B» harfi bilan boshlanadiganlarini ajratib olib, ulardan «bsinf.txt» faylini hosil qiluvchi dastur tuzing.
Program misol_3;
Uses crt;
var hafta: array[1..7]of string; f1,f2 : Text; s: string ; I: integer;
Begin clrscr
Assign(f1, 'c:sinf.txt'); Reset(f1);
Assign(f2, 'c:bsinf.txt'); Reset(f2);
For i:=1 to 7 do begin
Readln(f1,s); if s[1]= ‘B’ then Writeln(f2); end;
Close(f1); Close(f2); readln;
End.
4*. y=sm2x funksiyasining [-, ] oraliqdagi qiymatlarini 0,01 qadam bilan hisoblang. Natijalarni «sinus.out» faylida saqlab qo'ying.
Program misol_4;
Uses crt;
var ism: string; f : Text; I: integer;
Begin clrscr
Assign(f, 'c:sinf.txt'); Rewrite(f);
For i:=1 to 7 do begin
Writeln(I,’-o’quvchining familiyasi va ismini kiriting=’);
Readln(ism); writeln(f, ism); end; Close(f); readln;
End.
5*. «sinus.out» fayliga izoh qo'shuvchi dastur tuzing.
|