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 m,n,t,i:integer;
begin
clrscr;
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
t:=0;
for i:=m to n do
if i mod 2=0 then t:=t+i;
writeln('Tong cac so chan tu ',m,' den ',n,' la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
if (n%2==0)
{
t=0;
for (i=1; i<=n; i++) if (i%2==0) t+=i;
}
else
{
t=0;
for (i=1; i<=n; i++) if (i%2!=0) t+=i;
}
cout<<t;
return 0;
}
a)
uses crt;
var i,n:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n<100;
if n mod 2=0 then
begin
for i:=0 to n do
if i mod 2=0 then write(i:4);
end
else writeln(n,' khong la so chan');
readln;
end.
b)
uses crt;
var i,n:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n<100;
if n mod 2=1 then
begin
for i:=1 to n do
if i mod 2=1 then write(i:4);
end
else writeln(n,' khong la so le');
readln;
end.
{PROGRAM Bai_tap1;
USES crt;
VAR n, i, C, L:Bytbe;
BEGIN
clrscr;
Write('Nhap n:');Readln(n);
C:=0;L:=0;
For i:=1 to n do
If i mod 2=0 then C:=C+i else L:=L+i;
writeln('Tong cac so chan la:',C);
writeln ('Tong cac so le la:',L);
Readln;
end.
}
program Tong_Binh_Phuong_So_Chan;
uses crt;
var n, i, sum: integer;
begin
clrscr;
write('Nhap vao so nguyen n (6 < n < 30): ');
readln(n);
sum := 0;
for i := 2 to n do
if i mod 2 = 0 then
sum := sum + i * i;
writeln('Tong binh phuong cac so chan tu 1 den ', n, ' la: ', sum);
readln;
end.
Câu 1:
Program HOC24;
var i,p: integer;
t: longint;
begin
write('Nhap P: '); readln(p);
t:=0;
for i:=1 to p do if i mod 2<>0 then t:=t+i;
write('Tong cac so le la: ',t);
readln
end.
Câu 1:
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.
Câu 2:
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 = 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.
Câu 1:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 2 to n do
begin
if i mod 2 = 0 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so chan tu 2 toi ', n, ' la ', sum);
readln;
end.
Câu 2:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
if i mod 2 = 1 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so le tu 1 toi ', n, ' la ', sum);
readln;
end.
tk
uses crt;
var m,n,t,i:integer;
begin
clrscr;
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
t:=0;
for i:=m to n do
if i mod 2=0 then t:=t+i;
writeln('Tong cac so chan tu ',m,' den ',n,' la: ',t);
readln;
end.
uses crt;
var n,i,t,dem:integer;
begin
clrscr;
readln(n);
if n mod 2=0 then
begin
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
writeln(t);
end
else
begin
t:=0;
dem:=0;
for i:=1 to n do
if i mod 2=1 then
begin
t:=t+i;
dem:=dem+1;
end;
writeln(t/dem:4:2);
end;
readln;
end.