Bài Tập HSG về tệp
Chia sẻ bởi Trần Quang Diệu |
Ngày 26/04/2019 |
41
Chia sẻ tài liệu: Bài Tập HSG về tệp thuộc Tin học 11
Nội dung tài liệu:
CÁC BÀI TẬP VỀ TỆP1/ Program Tap_Tin_So_Nguyen;
Uses Crt;
Var
f : File Of Integer;
So : Integer;
a : Array[1..10] Of Integer;
Spt,i,j : Integer;
Filename : String[11];
Begin
ClrScr;
Writeln(`NHAP SO LIEU CHO TAP TIN SONGUYEN.DAT`);
Writeln(`-------------------------------------`);
Writeln;
Assign(f,`songuyen.dat`);
ReWrite(f);
For i := 1 To 10 Do
Begin
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f,so);
End;
Close(f);
Spt := 0;
Reset(f);
While NOT EOF(f) Do
Begin
Spt := Spt + 1;
Read(f,so);
a[Spt] := so;
End;
Close(f);
For i := 1 To Spt -1 Do
For j := Spt Downto i + 1 Do
If a[j] < a[j-1] Then
Begin
So := a[j];
a[j] := a[j-1];
a[j-1] := So;
End;
Writeln;
Writeln(`Sau khi sap xep: `);
For i := 1 To 10 Do
Write(a[i]:6);
Writeln;
Write(` Bam... `);
Readln
End.
2/ Program Ghep_Tap_Tin;
Uses Crt;
Var
f1,f2,f3 : File Of Real;
i : Integer;
So : Real;
Ch : Char;
Begin
ClrScr;
Writeln(`NHAP SO LIEU CHOAP1.DAT`);
Writeln(`-------------------------`);
Writeln;
Assign(f1,`TAP1.DAT`);
Rewrite(f1);
i := 0;
Repeat
i := i + 1;
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f1,so);
Write(` Nhap nua ? (c/k) `);
Readln(Ch);
Until Upcase(Ch) =`K`;
Close(f1);
ClrScr;
Writeln(`NHAP SO LIEU CHO TAP2.DAT`);
Writeln(`-------------------------`);
Writeln;
Assign(f2,`TAP2.DAT`);
Rewrite(f2);
i := 0;
Repeat
i := i + 1;
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f2,so);
Write(` Nhap nua ? (c/k) `);
Readln(Ch);
Until Upcase(Ch) =`K`;
Close(f2);
ClrScr;
Writeln(`GHEP TAP1 va TAP2 thanh TAP3`);
Writeln(`----------------------------`);
Writeln;
Assign(f3,`TAP3.DAT`);
Rewrite(f3);
Reset(f1);
Reset(f2);
While NOT EOF(f1) Do
Begin
Read(f1,So);
Write(f3,So);
End;
While NOT EOF(f2) Do
Begin
Read(f2,so);
Write(f3,so);
End;
Reset(f3);
While NOT EOF(f3) Do
Begin
Read(f3,So);
Write(So :8:1);
End;
Close(f1);
Close(f2);
Close(f3);
Writeln;
Writeln;
Write(‘Da ghep xong, Bam...`);
Readln;
End.
3/ Program Doc_Tung_Chu;
Uses Crt;
Var
Filename : String;
f : Text;
Line : String[251];
k : Integer;
Begin
ClrScr;
Writeln(`DOC CHAM TAP TIN THEO TUNG CHU`);
Writeln(`------------------------------`);
Writeln;
Write(`-Cho biet ten tap tin: `);
Readln(Filename);
Assign(f,Filename);
Uses Crt;
Var
f : File Of Integer;
So : Integer;
a : Array[1..10] Of Integer;
Spt,i,j : Integer;
Filename : String[11];
Begin
ClrScr;
Writeln(`NHAP SO LIEU CHO TAP TIN SONGUYEN.DAT`);
Writeln(`-------------------------------------`);
Writeln;
Assign(f,`songuyen.dat`);
ReWrite(f);
For i := 1 To 10 Do
Begin
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f,so);
End;
Close(f);
Spt := 0;
Reset(f);
While NOT EOF(f) Do
Begin
Spt := Spt + 1;
Read(f,so);
a[Spt] := so;
End;
Close(f);
For i := 1 To Spt -1 Do
For j := Spt Downto i + 1 Do
If a[j] < a[j-1] Then
Begin
So := a[j];
a[j] := a[j-1];
a[j-1] := So;
End;
Writeln;
Writeln(`Sau khi sap xep: `);
For i := 1 To 10 Do
Write(a[i]:6);
Writeln;
Write(` Bam
Readln
End.
2/ Program Ghep_Tap_Tin;
Uses Crt;
Var
f1,f2,f3 : File Of Real;
i : Integer;
So : Real;
Ch : Char;
Begin
ClrScr;
Writeln(`NHAP SO LIEU CHOAP1.DAT`);
Writeln(`-------------------------`);
Writeln;
Assign(f1,`TAP1.DAT`);
Rewrite(f1);
i := 0;
Repeat
i := i + 1;
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f1,so);
Write(` Nhap nua ? (c/k) `);
Readln(Ch);
Until Upcase(Ch) =`K`;
Close(f1);
ClrScr;
Writeln(`NHAP SO LIEU CHO TAP2.DAT`);
Writeln(`-------------------------`);
Writeln;
Assign(f2,`TAP2.DAT`);
Rewrite(f2);
i := 0;
Repeat
i := i + 1;
Write(`-So thu: `,i:2,` = `);
Readln(So);
Write(f2,so);
Write(` Nhap nua ? (c/k) `);
Readln(Ch);
Until Upcase(Ch) =`K`;
Close(f2);
ClrScr;
Writeln(`GHEP TAP1 va TAP2 thanh TAP3`);
Writeln(`----------------------------`);
Writeln;
Assign(f3,`TAP3.DAT`);
Rewrite(f3);
Reset(f1);
Reset(f2);
While NOT EOF(f1) Do
Begin
Read(f1,So);
Write(f3,So);
End;
While NOT EOF(f2) Do
Begin
Read(f2,so);
Write(f3,so);
End;
Reset(f3);
While NOT EOF(f3) Do
Begin
Read(f3,So);
Write(So :8:1);
End;
Close(f1);
Close(f2);
Close(f3);
Writeln;
Writeln;
Write(‘Da ghep xong, Bam
Readln;
End.
3/ Program Doc_Tung_Chu;
Uses Crt;
Var
Filename : String;
f : Text;
Line : String[251];
k : Integer;
Begin
ClrScr;
Writeln(`DOC CHAM TAP TIN THEO TUNG CHU`);
Writeln(`------------------------------`);
Writeln;
Write(`-Cho biet ten tap tin: `);
Readln(Filename);
Assign(f,Filename);
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...
Người chia sẻ: Trần Quang Diệu
Dung lượng: |
Lượt tài: 0
Loại file:
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)