HOC24
Lớp học
Môn học
Chủ đề / Chương
Bài học
program bai_tap; var i,d:integer; begin d:=0; for i:= 100 to 999 do begin if (i mod 2 = 0) and (i mod 3 = 0) and (i mod 5 = 0 ) then begin write(i,' '); inc(d); end; if d = 5 then begin d:=0; writeln; end; end; readln end.
program bai_tap; var t,k:integer; begin assign(input,'DULIEU.TXT'); reset(input); assign(output,'KETQUA.TXT'); rewrite(output); t:=0; while not eof(input) do begin read(k); t:=t+sqr(k); end; write(t); close(output); end.
kho......................wa........................troi.......................thi.....................ret...........................lanh........................wa..................tich.........................ung........................ho...........................minh.................nha..............cho..............do...........lanh
program bai_tap; i,d1,d2:integer;s:string; begin writeln('nhap s:'); readln(s); d1:=0;d2:=0; for i:= 1 to length(s) do if s[i] in ['A'..'Z'] then inc(d1) else inc(d2); writeln('co ',d1,' ki tu hoa'); writeln('co ',d2,' ki tu thuong'); readln end.
ý tưởng: -gọi d1 là số kí tự hoa,d2 là số kí tự thường -cho biến i chạy từ 1 đến length(s) -if s[i] in ['A'..'Z'] then inc(d1) else inc(d2);
program bai_tap; n:integer; begin writeln('nhap n:'); readln(n); if n mod 2 = 0 then writeln(n,': la so chan') else write(n,': la so le'); readln end.
program bai_tap; type mang = array[1..1000] of integer; var a:mang; i,j,n:integer;kt:boolean; begin writeln('nhap n:'); readln(n); i:=1; while i <= n do begin write('nhap so thu ',i,': '); readln(a[i]); if a[i] > 1 then begin kt:=true; for j:= 2 to trunc(sqrt(a[i])) do if a[i] mod j = 0 then begin kt:=false; break; end; if kt = true then writeln(a[i]); end; inc(i); end; readln end.
program bai_tap; type mang = array[1..1000] of integer; var a:mang; i,j,n:integer; begin writeln('nhap n:'); readln(n); i:=1;j:=0; while i <= n do begin write('nhap so thu ',i,': '); readln(a[i]); if a[i] mod 2 = 0 then j:=j+a[i]; inc(i); end; write(j); readln end.
0,06% = 6/10000
Vậy chọn phương án D
câu 4)
program bai_tap; uses crt; var n,i:byte; k:integer; a:array[1..100] of integer; begin clrscr; write('nhap so luong phan tu cua mang: '); readln(n); for i:= 1 to n do begin write('A[',i,'] = '); write(a[i]); end; write('nhap gia tri phan tu K: '); readln(K); for i:= 1 to n do if a[i] = k then begin write('vi tri cua K la: ',i); break; {vì tìm 1 phần tử} end; readln end.