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 TongSoChan;
var
n, i, x, tong: integer;
begin
write('Nhap so nguyen n: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
read(x);
if x mod 2 = 0 then
tong := tong + x;
end;
writeln('Tong cac so chan la: ', tong);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t=t+i;
cout<<t;
return 0;
}
n = int(input())
if n % 2 != 0:
n -= 1
so_so_hang = (n - 2) // 2 + 1
print((n + 2)*so_so_hang // 2)
Bài 3:
uses crt;
var i:integer;
{------------------chuong-trinh-con-kiem-tra-so-nguyen-to----------------------}
function ktnt(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to x-1 do
if x mod i=0 then kt:=false;
if kt=true then ktnt:=true
else ktnt:=false;
end;
{-------------------------chuong-trinh-chinh----------------------------}
begin
clrscr;
for i:=2 to 9999 do
if (ktnt(i)=true) and (ktnt(i+2)=true) then
begin
writeln(i,',',i+2);
delay(500);
end;
readln;
end.
Bài 4:
uses crt;
var a,b,c,kt:integer;
begin
clrscr;
write('Nhap ngay:'); readln(a);
write('Nhap thang:'); readln(b);
write('Nhap nam:'); readln(c);
kt:=0;
if (b=1) and (0<a) and (a<=31) then kt:=1;
if (b=2) and (0<a) and (a<=28) then kt:=1;
if (b=2) and (0<a) and (a<=29) and (c mod 4=0) then kt:=1;
if (b=3) and (0<a) and (a<=31) then kt:=1;
if (b=4) and (0<a) and (a<=30) then kt:=1;
if (b=5) and (0<a) and (a<=31) then kt:=1;
if (b=6) and (0<a) and (a<=30) then kt:=1;
if (b=7) and (0<a) and (a<=31) then kt:=1;
if (b=8) and (0<a) and (a<=31) then kt:=1;
if (b=9) and (0<a) and (a<=30) then kt:=1;
if (b=10) and (0<a) and (a<=31) then kt:=1;
if (b=11) and (0<a) and (a<=30) then kt:=1;
if (b=12) and (0<a) and (a<=31) then kt:=1;
if kt=0 then writeln('Khong hop le')
else writeln('Hop le');
readln;
end.