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.
uses crt;
var a,b:array[1..100]of integer;
n,i,dem,max,tam,j:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chia het cho 4 la: ');
for i:=1 to n do
if a[i] mod 4=0 then write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 7=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
max:=b[1];
for i:=1 to dem do
if max<b[i] then max:=b[i];
writeln('So lon nhat chia het cho 7 la: ',max);
writeln('Cac chi so cua no trong day A la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day so sau khi sap xep giam dan la: ');
for i:=1 to n do
write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
inc(dem);
write(a[i]:4);
end;
writeln;
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.
Câu 3:
#include <bits/stdc++.h>
using namespace std;
string a[1000];
int n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]=='a') dem++;
}
cout<<dem;
return 0;
}
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)
uses crt;
var a:array[1..250]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
for i:=1 to n do t:=t+a[i];
writeln(t);
readln;
end.
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 1:
uses crt;
var b:array[1..100]of real;
i,n:integer;
min:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
min:=b[1];
for i:=1 to n do
if min>b[i] then min:=b[i];
writeln('Gia tri nho nhat la: ',min:4:2);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day giam dan la: ');
for i:=1 to n do write(a[i]:4);
readln;
end.