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.
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.
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.
c1:
#include <bits/stdc++.h>
using namespace std;
long long i,n,s;
int main()
{
cin>>n;
s=1;
for (i=1; i<=n; i++) s=s*i;
cout<<s;
return 0;
}
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long i,n,s;
int main()
{
cin>>n;
s=1;
for (i=1; i<=n; i++) if (i%2==0) s=s*i;
cout<<s;
return 0;
}
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.
{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.
}
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
write(t);
readln;
end.
program Chan_Le;
var
n, i: integer;
begin
write('Nhap vao so nguyen N: ');
readln(n);
writeln('Cac so chan tu 1 den ', n, ' la:');
for i := 2 to n do
begin
if i mod 2 = 0 then
begin
write(i, ' ');
end;
end;
writeln;
writeln('Cac so le tu 1 den ', n, ' la:');
for i := 1 to n do
begin
if i mod 2 <> 0 then
begin
write(i, ' ');
end;
end;
readln;
end.
program Chan_Le;
var n, i: integer;
begin
write('Nhap vao so nguyen n: ');
readln(n);
writeln('Cac so chan tu 1 den ',n, ' la: ');
for i := 1 to n do
begin
if i mod 2 = 0 then
write(i, ' ');
end;
writeln;
writeln('Cac so le tu 1 den ', n, ' la: ');
for i := 1 to n do
begin
if i mod 2 <> 0 then
write(i, ' ');
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n,s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
if (i%2==0) s=s+i;
cout<<s;
return 0;
}