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.

4 tháng 3 2021

program trungbinhcong;

uses crt;

var a: array[1..80]of integer;      tb: real;      tong: integer;      i,n,sl: byte; begin clrscr; writeln('nhap n: '); readln(n); for i:= 1 to n do    begin        writeln('nhap a[',i,']: ');        readln(a[i]);    end; tong:=0; sl:=0; for i:= 1 to n do    if (a[i] mod 2 <> 0) then        begin            sl:=sl+1;            tong:=tong+a[i];        end; tb:=tong/sl; writeln('trung binh cong cua cac phan tu le trong mang la: ', tb:4:3); readlnend.

Câu 24. Trong pascal, cho đoạn chương trình:Assign(f1,‟Input.dat‟); Reset(f1);While not eoln(f1) do BeginRead(f1,x);Write(x, ‘ '); End;Close(f1); A. Xuất dữ liệu trong tệp Input.dat ra màn hình;   B. Ghi dữ liệu vào tệp Input.dat; C. Gắn tên tệp Input.Dat cho biến tệp f1;              D. Mở tệp Input.dat để đọc; Câu 25. Đoạn chương trình sau thực hiện: Assign(f1,‟Input.dat‟); Assign(f2,‟Output.dat‟); Reset(f1); Rewrite(f2);While not EOF(f1)...
Đọc tiếp

Câu 24Trong pascal, cho đoạn chương trình:Assign(f1,‟Input.dat‟); Reset(f1);

While not eoln(f1) do 

Begin

Read(f1,x);Write(x, ‘ '); 

End;

Close(f1);

 

A. Xuất dữ liệu trong tệp Input.dat ra màn hình;   B. Ghi dữ liệu vào tệp Input.dat;

 

C. Gắn tên tệp Input.Dat cho biến tệp f1;              D. Mở tệp Input.dat để đọc;

 

Câu 25. Đoạn chương trình sau thực hiện: Assign(f1,‟Input.dat‟); Assign(f2,‟Output.dat‟); Reset(f1); Rewrite(f2);

While not EOF(f1) do

Begin

Read(f1,x); Write(f2,x,’ ’);

End;

Close(f1); 

Close(f2);

 

Đọc dữ liệu từ tệp Input.dat và ghi dữ liệu ra tệp Output.dat trên cùng một dòng.

B.Đọc dữ liệu từ tệp Input.dat và ghi dữ liệu ra tệp Output.dat trên nhiều dòng.

Đọc dữ liệu từ tệp Output.dat và ghi dữ liệu ra tệp Input.dat trên nhiều dòng.

Đọc dữ liệu từ tệp Output.dat và ghi dữ liệu ra tệp Intput.dat trên cùng một dòng.

 

Câu 26. Cho tệp B13.TXT chỉ có một dòng „abcdefgh‟ và chương trình sau: Var f:text; S1:string[3]; S2:string;

Begin

Assign(f,’B13.TXT’); 

Reset(f); 

Read(f,S2,S1);

Readln

End.

 

Sau khi chạy chương trình trên thì S1,S2 có kết quả là

 

a. S1=’absdefgh’; S2=’ ’

b. S1=’ ’; S2=’abcdefgh’

 c. S1=’abcde’;S2=’fgh’

d. Cả a,b,c sai

1

Câu 24: A

Câu 25: A

 

uses crt;

var a:array[1..100]of integer;

i,n:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

writeln('Chi so cua so hang cuoi cung la: ',n);

readln;

end.

Nhập xong rồi làm gì nữa bạn?

uses crt;

var a:array[1..250]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then t:=t+a[i];

writeln(t);

readln;

end.

uses crt;

var a:array[1..250]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then t:=t+a[i];

writeln(t);

readln;

end.

23 tháng 2 2021

bổ sung đề nha

Nhập xong rồi làm gì nữa bạn?

23 tháng 2 2021

Program FNG;

Uses crt;Var A: array[1..1000] of longint;    n,i,s,da,sa: longint;Begin        Clrscr;        Write('Nhap n: '); Readln(n);        s:=0; da:=0; sa:=0;        For i:=1 to n do        Begin                Write('A[',i,'] = ');                Readln(A[i]);                s:=s+A[i];                If A[i]<0 then                Begin                        inc(da);                        sa:=sa+A[i];                End;        End;        Writeln('S = ',s);        Writeln('Dem am = ',da)        Write('Tong am = ',sa);        ReadlnEnd.

Nhập mảng xong rồi làm gì nữa bạn?

const fi='inp.inp';

       fo='out.inp';

var f1,f2:text;

st:array[1..100]of string;

i,n:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

readln(f1,st[n]);

end;

for i:=1 to n do 

  writeln(f2,length(st[i]));

close(f1);

close(f2);

end.