K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

Program Piano; uses crt,graph; const SoPhim = 14; Phim: array[1..SoPhim] of char = ('a','s','d','f','g','h','j', '1','2','3','4','5','6','7'); TenNot: array[1..SoPhim] of string[3] = ('Do','Re','Mi','Fa', 'Sol','La','Si','Do"','Re"','Mi"','Fa"','Sol"','La"','Si"'); AmThanh: array[1..SoPhim] of integer = (131,147,165,175,196,220, 247,262,294,330,349,392,440,494); CRong = 30; Cdai = 100; KCNgang = 80; KCDoc = 150; _MauPhim = LightGreen; var gd,gm: integer; MauPhim: array[1..SoPhim] of integer; k: char; TgPhat: integer; f: text; GA,Playing: Boolean; Procedure InPhimDan(i: integer); Begin if MauPhim[i] = _MauPhim then SetFillStyle(1,_MauPhim) else SetFillStyle(1,White); bar(KCNgang+i*CRong,KCDoc,KCNgang+(i+1)*CRong,KCDoc + CDai); SetFillStyle(1,8); bar(KCNgang+i*CRong,KCdoc + CDai,KCNgang+(i+1)*CRong, KCDoc + CDai + 5); SetFillStyle(1,LightGray); bar(KCNgang+i*CRong,KCdoc + CDai+5,KCNgang+(i+1)*CRong, KCDoc + CDai + 10); SetColor(Black); Rectangle(KCNgang+i*CRong,KCDoc,KCNgang+(i+1)*CRong,KCDoc + CDai+10); SetColor(Blue); OutTextXY(KCNgang+i*30+15,KCDoc+70,Phim[i]); OutTextXY(KCNgang+i*30+5,KCDoc+20,TenNot[i]); End; Procedure TaoDan; var i: integer; Begin SetFillStyle(1,Cyan); Bar(KCNgang + CRong - 10,KCDoc - 10,KCNgang + CRong*(SoPhim+1)+10,KCDoc+CDai+20); for i := 1 to SoPhim do InPhimDan(i); Setcolor(Brown); SetTextStyle(DefaultFont, HorizDir,3); OutTextXy(200,100,'P I A N O'); SetTextStyle(DefaultFont, HorizDir,1); OutTextXy(200,320,'Turn off VietKey before hitting.'); End; Procedure ShowDan; var trdo: string; Begin SetfillStyle(1,LightGreen); Bar(KCNgang+CRong,KCDoc+Cdai+20,KCNgang + (SoPhim+1)*Crong,KCDoc+CDai+60); {--Record--} SetFillStyle(1,Red); Bar(KCNgang+CRong+20,KCdoc + CDai+25,KCNgang+CRong+80,KCDoc+CDai+55); Setcolor(Black); if not GA then OutTextXy(KCNgang+CRong+25,KCdoc + CDai+30,'Record') else OutTextXy(KCNgang+CRong+25,KCdoc + CDai+30,'Rec...'); OutTextXy(KCNgang+CRong+30,KCdoc + CDai+45,'( R )'); {--Truong Do--} SetFillStyle(1,Blue); Bar(KCNgang+CRong*(SoPhim+1)-80,KCdoc + CDai+25, KCNgang+CRong*(SoPhim+1)-10,KCDoc+CDai+55); Setcolor(Black); OutTextXy(KCNgang+CRong*(SoPhim+1)-70,KCdoc + CDai+35,'T: '); Str(TgPhat,trDo); OutTextXy(KCNgang+CRong*(SoPhim+1)-50,KCdoc + CDai+35,trdo); {--Play--} SetFillStyle(1,Yellow); Bar(KCNgang+CRong+170,KCdoc + CDai+25,KCNgang+CRong+230,KCDoc+CDai+55); Setcolor(Black); if not Playing then OutTextXy(KCNgang+CRong+185,KCdoc + CDai+30,'Play') else OutTextXy(KCNgang+CRong+185,KCdoc + CDai+30,'Stop'); OutTextXy(KCNgang+CRong+180,KCdoc + CDai+45,'( P )'); End; Procedure GhiAm(kt:string;Am: integer); var s: array[1..3000] of string[4]; i,j: integer; Begin reset(f); i := 0; repeat inc(i); Readln(f,s[i]); until s[i] = ''; rewrite(f); for j := 1 to i-1 do writeln(f,s[j]); if kt = '' then Writeln(f,Am) else Writeln(f,kt,Am); Close(f); End; Procedure Play; var s: string; i,c,j:integer; Begin reset(f); repeat readln(f,s); Val(s,i,c); if c = 0 then begin Sound(AmThanh[i]); for j := 1 to SoPhim do if i = j then begin MauPhim[j] := _MauPhim; InPhimDan(j); end else if MauPhim[j] = _MauPhim then begin MauPhim[j] := White; InPhimDan(j); end; end else begin Val(Copy(s,2,Length(s)),i,c); Delay(i); NoSound; end; k := #0; if keypressed then k := readkey; until (s = '') or (k = 'p'); Playing := False; ShowDan; End; Procedure TruongDo; Begin if (k = #72) or (k = #80) then begin if (k = #72) and (TgPhat < 400) then inc(TgPhat,50) else if (k = #80) and (TgPhat > 50) then inc(TgPhat,-50); ShowDan; end; End; Procedure BatGhiAm; Begin if k = 'r' then begin if not GA then ReWrite(f); GA := not GA; ShowDan; end else if k = 'p' then begin Playing := True;ShowDan;Play;end; End; Procedure DanhDan; var i: integer; Begin k := #0; if keypressed then begin k := readkey;TruongDo;BatGhiAm;end; for i := 1 to SoPhim do begin if k = Phim[i] then begin MauPhim[i] := _MauPhim; Sound(AmThanh[i]); InPhimDan(i); if GA then begin GhiAm('',i); GhiAm('d',tgPhat); end; end else if MauPhim[i] = _MauPhim then begin MauPhim[i] := White; InPhimDan(i); end; end; if k <> #0 then delay(tgPhat); NoSound; End; BEGIN gd := EGA; gm := EGAHI; InitGraph(gd,gm,''); SetBkColor(Black); Assign(f,'GhiAm.txt'); {ReWrite(f);} { Bo dau ngoac trong lan chay dau tien, sau do dong lai} TaoDan; TgPhat := 200; GA := False; Playing := False; ShowDan; repeat DanhDan; if GA then ghiAm('d',23); until k = #27; CloseGraph; END.Program Piano; uses crt,graph; const SoPhim = 14; Phim: array[1..SoPhim] of char = ('a','s','d','f','g','h','j', '1','2','3','4','5','6','7'); TenNot: array[1..SoPhim] of string[3] = ('Do','Re','Mi','Fa', 'Sol','La','Si','Do"','Re"','Mi"','Fa"','Sol"','La"','Si"'); AmThanh: array[1..SoPhim] of integer = (131,147,165,175,196,220, 247,262,294,330,349,392,440,494); CRong = 30; Cdai = 100; KCNgang = 80; KCDoc = 150; _MauPhim = LightGreen; var gd,gm: integer; MauPhim: array[1..SoPhim] of integer; k: char; TgPhat: integer; f: text; GA,Playing: Boolean; Procedure InPhimDan(i: integer); Begin if MauPhim[i] = _MauPhim then SetFillStyle(1,_MauPhim) else SetFillStyle(1,White); bar(KCNgang+i*CRong,KCDoc,KCNgang+(i+1)*CRong,KCDoc + CDai); SetFillStyle(1,8); bar(KCNgang+i*CRong,KCdoc + CDai,KCNgang+(i+1)*CRong, KCDoc + CDai + 5); SetFillStyle(1,LightGray); bar(KCNgang+i*CRong,KCdoc + CDai+5,KCNgang+(i+1)*CRong, KCDoc + CDai + 10); SetColor(Black); Rectangle(KCNgang+i*CRong,KCDoc,KCNgang+(i+1)*CRong,KCDoc + CDai+10); SetColor(Blue); OutTextXY(KCNgang+i*30+15,KCDoc+70,Phim[i]); OutTextXY(KCNgang+i*30+5,KCDoc+20,TenNot[i]); End; Procedure TaoDan; var i: integer; Begin SetFillStyle(1,Cyan); Bar(KCNgang + CRong - 10,KCDoc - 10,KCNgang + CRong*(SoPhim+1)+10,KCDoc+CDai+20); for i := 1 to SoPhim do InPhimDan(i); Setcolor(Brown); SetTextStyle(DefaultFont, HorizDir,3); OutTextXy(200,100,'P I A N O'); SetTextStyle(DefaultFont, HorizDir,1); OutTextXy(200,320,'Turn off VietKey before hitting.'); End; Procedure ShowDan; var trdo: string; Begin SetfillStyle(1,LightGreen); Bar(KCNgang+CRong,KCDoc+Cdai+20,KCNgang + (SoPhim+1)*Crong,KCDoc+CDai+60); {--Record--} SetFillStyle(1,Red); Bar(KCNgang+CRong+20,KCdoc + CDai+25,KCNgang+CRong+80,KCDoc+CDai+55); Setcolor(Black); if not GA then OutTextXy(KCNgang+CRong+25,KCdoc + CDai+30,'Record') else OutTextXy(KCNgang+CRong+25,KCdoc + CDai+30,'Rec...'); OutTextXy(KCNgang+CRong+30,KCdoc + CDai+45,'( R )'); {--Truong Do--} SetFillStyle(1,Blue); Bar(KCNgang+CRong*(SoPhim+1)-80,KCdoc + CDai+25, KCNgang+CRong*(SoPhim+1)-10,KCDoc+CDai+55); Setcolor(Black); OutTextXy(KCNgang+CRong*(SoPhim+1)-70,KCdoc + CDai+35,'T: '); Str(TgPhat,trDo); OutTextXy(KCNgang+CRong*(SoPhim+1)-50,KCdoc + CDai+35,trdo); {--Play--} SetFillStyle(1,Yellow); Bar(KCNgang+CRong+170,KCdoc + CDai+25,KCNgang+CRong+230,KCDoc+CDai+55); Setcolor(Black); if not Playing then OutTextXy(KCNgang+CRong+185,KCdoc + CDai+30,'Play') else OutTextXy(KCNgang+CRong+185,KCdoc + CDai+30,'Stop'); OutTextXy(KCNgang+CRong+180,KCdoc + CDai+45,'( P )'); End; Procedure GhiAm(kt:string;Am: integer); var s: array[1..3000] of string[4]; i,j: integer; Begin reset(f); i := 0; repeat inc(i); Readln(f,s[i]); until s[i] = ''; rewrite(f); for j := 1 to i-1 do writeln(f,s[j]); if kt = '' then Writeln(f,Am) else Writeln(f,kt,Am); Close(f); End; Procedure Play; var s: string; i,c,j:integer; Begin reset(f); repeat readln(f,s); Val(s,i,c); if c = 0 then begin Sound(AmThanh[i]); for j := 1 to SoPhim do if i = j then begin MauPhim[j] := _MauPhim; InPhimDan(j); end else if MauPhim[j] = _MauPhim then begin MauPhim[j] := White; InPhimDan(j); end; end else begin Val(Copy(s,2,Length(s)),i,c); Delay(i); NoSound; end; k := #0; if keypressed then k := readkey; until (s = '') or (k = 'p'); Playing := False; ShowDan; End; Procedure TruongDo; Begin if (k = #72) or (k = #80) then begin if (k = #72) and (TgPhat < 400) then inc(TgPhat,50) else if (k = #80) and (TgPhat > 50) then inc(TgPhat,-50); ShowDan; end; End; Procedure BatGhiAm; Begin if k = 'r' then begin if not GA then ReWrite(f); GA := not GA; ShowDan; end else if k = 'p' then begin Playing := True;ShowDan;Play;end; End; Procedure DanhDan; var i: integer; Begin k := #0; if keypressed then begin k := readkey;TruongDo;BatGhiAm;end; for i := 1 to SoPhim do begin if k = Phim[i] then begin MauPhim[i] := _MauPhim; Sound(AmThanh[i]); InPhimDan(i); if GA then begin GhiAm('',i); GhiAm('d',tgPhat); end; end else if MauPhim[i] = _MauPhim then begin MauPhim[i] := White; InPhimDan(i); end; end; if k <> #0 then delay(tgPhat); NoSound; End; BEGIN gd := EGA; gm := EGAHI; InitGraph(gd,gm,''); SetBkColor(Black); Assign(f,'GhiAm.txt'); {ReWrite(f);} { Bo dau ngoac trong lan chay dau tien, sau do dong lai} TaoDan; TgPhat := 200; GA := False; Playing := False; ShowDan; repeat DanhDan; if GA then ghiAm('d',23); until k = #27; CloseGraph; END.
1
18 tháng 12 2020

sửa lỗi giúp mình nhé

 

18 tháng 12 2020

dễ ấy mà :))

thực hiện công việc nhập n số từ bàn phím

Đúng rồi đó bạn

11 tháng 4 2020

đúng ko ạ

11 tháng 4 2021

Câu 3-NB: Phương án nào dưới đây là khai báo mảng hợp lệ?

A. Var mang : ARRAY[0..10] OF INTEGER; 

B. Var mang : ARRAY[0..10] : INTEGER;

C. Var mang : INTEGER OF ARRAY[0..10];

D. Var mang : ARRAY(0..10) : INTEGER;

Chọn A

21 tháng 12 2018

Sữa lỗi:

phần khai báo:a:array[1..250] of integer (ngoặc vuông ko phải ngoặc tròn)

1. Đâu là câu lệnh in ra màn hình A. Wsescrt B. Writech (Hello) C. Program BT- Tin học D. Readln (Hello) 2. Cho đoạn công thức sau: j=0, For: 0 to 5 do j= t2 sau khi thực hiện đoạn công thức trên thì giá trị của biến j bằng bao nhiêu. A. 15 B.12 C.11 D.20 3. Ta thực hiện lệnh gán sau: x=1, y=9, z= x+y. Giá trị của biến z là: A.9 B.10 C.1 ...
Đọc tiếp

1. Đâu là câu lệnh in ra màn hình

A. Wsescrt B. Writech (Hello) C. Program BT- Tin học D. Readln (Hello)

2. Cho đoạn công thức sau: j=0, For: 0 to 5 do j= t2 sau khi thực hiện đoạn công thức trên thì giá trị của biến j bằng bao nhiêu.

A. 15 B.12 C.11 D.20

3. Ta thực hiện lệnh gán sau: x=1, y=9, z= x+y. Giá trị của biến z là:

A.9 B.10 C.1 D. Kết quả khác

4. Nhặt đỗ đen ra khỏi lạc cho đến khi trong lạc không còn đỗ đen.

A. Lặp với số lần chưa biết trước. B. Lặp 10 lần

C. Lặp vô số lần D. Lặp với số lần biết trước.

5. Trong các biến mảng sau đây, cách khai báo nào hợp lệ.

A) var a : array [ 1....100] of integer B) var a : array [1.5, 100.5] of integer

B) var a : array [ 1.5 ... 100.5] of integer D) var a : array [1 ... 100] of read

6. Hãy chọn kết quả đúng.

A. 14/5 = 2 B. 14*5 = 19 C. 14 div 5= 2 D. 14 mod 5= 3

(Có thể thì cho mình xin giải thích vì sao lại khoanh vào câu đó nhé! )

1
25 tháng 4 2019

1.A

2. ko tìm ra dc vì sai cú pháp

3.B

4.A

5.D

6.C

17 tháng 5 2021

sữa i bằng b đi bạn ơi

11 tháng 5 2020

Mình kiểm tra thấy nó có sai về lỗi gì đâu. Ý bạn là sai về cách chạy đúng không, bạn gửi đề để mình xem nhé

1) Kiểu dữ liệu của các phần tử trong mảng là: a) Mỗi phần tử là 1 kiểu b) Có cùng một kiểu dữ liệu c) Có cùng một kiểu đó là kiểu số nguyên d) có cùng một kiểu đó là kiểu số thực. 2) Cú pháp nào sau đây là đúng? a) Type mang: array [-100 to 100] of integer; b) Type mang =array[-100 to 100] of integer; c) Type mang: array[-100..100] of integer; d)Type mang =array[-100..100] of integer; 3) Cú pháp câu lệnh...
Đọc tiếp

1) Kiểu dữ liệu của các phần tử trong mảng là:

a) Mỗi phần tử là 1 kiểu

b) Có cùng một kiểu dữ liệu

c) Có cùng một kiểu đó là kiểu số nguyên

d) có cùng một kiểu đó là kiểu số thực.

2) Cú pháp nào sau đây là đúng?

a) Type mang: array [-100 to 100] of integer;

b) Type mang =array[-100 to 100] of integer;

c) Type mang: array[-100..100] of integer;

d)Type mang =array[-100..100] of integer;

3) Cú pháp câu lệnh nào sau đây đúng?

a) Var mang: array[1...100,1...100] of char;

b) Var mang: array[1...100; 1...100] of char;

c) Var mang2c: array(1..100,1..100) of char;

d) Var mang2c: array[1..100, 1..100] of char;

4) Cú pháp câu lệnnh nào sau đây đúng?

a) Type mang: array [-100 to 100, -100 to 100] of integer;

b) Type mang: array [-100..100,-100..100] of integer;

c) Type mang = array [-100 to 100, -100 to 100] of integer;

d) Type mang = array [-100..100, -100..100] of integer;

5) Với khai báo A:array[1..100,1..100] of integer; thì việc truy xuất đến các phần tử như sau:

a) A( i , j )

b) A[ i , j ]

c) A( i ; j )

d) A[ i ; j ]

6) Xâu ' ABBA ' bằng xâu:

a) 'A'

b) 'B'

c) 'abba'

d) Tất cả đều sai.

7) Xâu '2007' nhỏ hơn xâu:

a) '20007'

b) '207'

c) '1111111111'

d) '1010101010'

8) Hàm copy (s,p,n) cho giá trị là:

a) Một xâu gồm n kí tự liên tiếp bắt đầu từ vị trí p của xâu S

b) Một xâu gồm p kí tự liên tiếp bắt đầu từ vị trí n của xâu S

c) Một xâu gồm n kí tự liên tiếp bắt đầu từ vị trí p-n của xâu S

d) Một xâu gồm p kí tự liên tiếp bắt đầu từ vị trí n-p của xâu S

9) Trong các phát biểu sau, phát biểu nào đúng:

a) Có thể nhập giá trị của một biến kiểu bản ghi như nhập giá trị của biến kiểu dữ liệu chuẩn.

b) Có thể xuất giá trị của một biến kiểu bản ghi như xuất giá trị của biến kiểu dữ liệu chuẩn.

c) Có thể nhập hay xuất giá trị của một biến kiểy bản ghi như nhập hay xuất giá trị của biến kiểu dữ liệu chuẩn.

d) Các thao tác nhập, xuất hhay xử lý mỗi trường bản ghi phải tuân theo quy định của kiểu trường này..

10) Để truy cập dữ liệu của trường nào đó trên biến bản ghi ta sử dụng cú pháp:

a) Tên trường. tên biến;

b) Tên trường: tên biến;

c) Tên biến. tên trường;

d) Tên biến: tên trường

11) Để truy xuất đến các phần tử của mảng 1 chiều ta dùng mấy vòng lặp for.....do

a) 1

b) 2

c) 3

d) 4

12) Để truy xuất đến các phần tử của mảnh 2 chiều ta dùng mấy vòng lặp for.....do

a) 1

b) 2

c) 3

d) 4

0