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 vdd;
uses crt;
var i,n: integer;
begin
clrscr;
write('Nhap N: '); readln(n);
for i:=1 to n do if i mod 2=1 then write(i,';');
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 inc(dem);
writeln(dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[1..100]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.
#include <bits/stdc++.h>
using namespace std;
int n,A[1000],i,dem=0,t=0;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
for (int i=1; i<=n; i++)
{
if (A[i]%3!=0) dem++;
if (A[i]%4==2) t+=A[i];
}
cout<<dem<<endl;
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000],t,dem,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
cout<<endl;
t=0;
dem=0;
for (i=1; i<=n; i++)
if (a[i]%2==0)
{
t=t+a[i];
dem++;
}
cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0)<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0 || a[i]%3==0) t1+=a[i];
cout<<t1;
return 0;
}
Câu 1:
uses crt;
var a,b,c,p,s:real;
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
until (a>0) and (b>0) and (c>0);
if (a+b>c) and (a+c>b) and (b+c>a) then
begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich tam giac la: ',s:4:2);
end
else writeln('Day khong la ba canh trong mot tam giac');
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,max,min: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
t:=t+a[i];
writeln('Tong cac phan tu trong day la: ',t);
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
nếu câu b bài 2 được tách riêng thành 1 câu riêng biệt...thì thay thế bắt đầu từ đâu ạ
uses crt;
var a,b,c,d,tl,tc:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
write('Nhap d='); readln(d);
tc:=0;
tl:=0;
if a mod 2=0 then tc:=tc+a
else tl:=tl+a;
if b mod 2=0 then tc:=tc+b
else tl:=tl+b;
if c mod 2=0 then tc:=tc+c
else tl:=tl+c;
if d mod 2=0 then tc:=tc+d
else tl:=tl+d;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
readln;
end.
uses crt;
var i:integer;
begin
clrscr;
for i:=1 to 100 do
if i mod 2=1 then write(i:4);
readln;
end.