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.
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.
uses crt;
var n,i,t,s:integer;
begin
clrscr;
repeat
readln(n);
until n<>0;
t:=0;
for i:=1 to n do if i mod 2=0 then t:=t+i;
writeln(t);
s:=1;
for i:=1 to n do
if i mod 2=1 then s:=s*i;
writeln(s);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,s;
int main()
{
cin>>n;
if (n%2==0)
{
s=1;
for (i=1; i<=n; i++)
if (i%2==0) s=s*i;
cout<<s;
}
else
{
s=1;
for (i=1; i<=n; i++)
if (i%2==1) s=s*i;
cout<<s;
}
return 0;
}
program Le_Nho_Hon_Hoac_Bang_n;
uses crt;
var
n, i: integer;
begin
clrscr;
write('Nhap vao mot so nguyen duong n: ');
readln(n);
while n <= 0 do
begin
writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');
readln(n);
end;
clrscr;
writeln('Cac so le nho hon hoac bang ', n, ' la:');
i := 1;
while i <= n do
begin
if i mod 2 <> 0 then
writeln(i);
i := i + 1;
end;
readln;
end.
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;
}
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.
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.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
Write('Cac phan tu vua nhap la ');
For i:=1 to n do
Write(a[i]:8);
Writeln;
Write('Tong cua chung la ',s);
Readln
End.
có gh của n ko bạn!
var i,n:integer;
s:real;
begin
write('Nhap n = ');readln(n);
s:=1;
if n mod 2 = 0 then
begin
for i:=2 to n do
begin
s:=s*i;
i:=i+2;
end;
end
else
begin
for i:=1 to n do
begin
s:=s*i;
i:=i+2;
end;
write('Tong la ',s:10:2);
readln;
end.