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:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('Trong day co ',dem,' so chan');
readln;
end.
Bài 1:
uses crt;
var m,n,i,t:integer;
begin
clrscr;
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
t:=0;
for i:=m to n do
t:=t+i;
writeln(t);
readln;
end.
2:
uses crt;
var n:integer;
{---------------chuong-trinh-con-kiem-tra-chan-le---------------------}
function ktcl(x:integer):boolean;
begin
if x mod 2=0 then ktcl:=true
else ktcl:=false;
end;
{--------------------chuong-trinh-con-kiem-tra-duong-am-------------------}
fucntion ktda(x:integer):boolean;
begin
if x>0 then ktda:=true
else if x<0 then ktda:=false;
end;
{--------------------chuong-trinh-chinh-------------------------}
begin
clrscr;
write('Nhap n='); readln(n);
if ktcl(n)=true then writeln('Day la so chan')
else writeln('Day la so le');
if ktda(n)=true then writeln('Day la so duong')
else writeln('Day la so am');
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]>10 then inc(dem);
writeln('So phan tu lon hon 10 la: ',dem);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
writeln('So luong so chan la: ',dem1);
writeln('So luong so le la: ',dem2);
t:=0;
s:=1;
for i:=1 to n do
begin
if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];
if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];
end;
writeln('Tong cac so o vi tri chan co gia tri le la: ',t);
writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chan va lon hon 10 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);
readln;
end.
#include <iostream>
using namespace std;
int main()
{
int a[100][100],i,j,m,n;
cout<<"Nhap so dong cua mang:"; cin>>n;
cout<<"Nhap so cot cua mang:"; cin>>m;
for (i=1; i<=n; i++)
for (j=1; j<=m; j++)
{
cout<<"A["<<i<<","<<j<<"]="; cin>>a[i][j];
}
for (i=1; i<=n; i++)
{
for (j=1; j<=m; j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,i,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 2=0 then inc(dem);
writeln('So phan tu chan la: ',dem);
readln;
end.
uses crt;
var i,n,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
writeln('Cac so chan va chia het cho 4 trong khoang tu 5 toi ',n,' la: ');
for i:=5 to n do
if (i mod 2=0) and (i mod 7=0) then write(i:4);
writeln;
writeln('Cac so chia het cho 7 trong khoang tu 5 toi ',n,' la: ');
dem:=0;
for i:=5 to n do
if i mod 7=0 then
begin
write(i:4);
inc(dem);
end;
writeln;
writeln('Co ',dem,' so chia het cho 7 trong khoang tu 5 toi ',n);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
if (i%2==0) cout<<i<<" ";
cout<<endl;
for (i=1; i<=n; i++)
if (i%2==1) cout<<i<<" ";
cout<<endl;
}
#include <bits/stdc++.h>
using namespace std;
long long a,b,i,dem;
int main()
{
cin>>a>>b;
dem=0;
for (i=a; i<=b; i++) if (i%2==0) dem++;
cout<<dem;
}
Var n1,n2,i,dem:integer;
Begin
Write('Nhap n1 = ');readln(n1);
Write('Nhap n2 = ');readln(n2);
For i:=n1 to n2 do
If i mod 2 = 0 then dem:=dem+1;
Write('Co ',dem,' so chan');
Readln;
End.