Viết chương trình in ra các số chẵn nhỏ hơn hoặc bằng n.
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.
#include <bits/stdc++.h>
using namespace std;
long long i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) if (i%2==0) cout<<i<<" ";
return 0;
}
Var n,i,so:integer;
Begin
Write('Nhap n = ');readln(n);
Writeln('Cac so chan tu 1 den n la: ');
For i:=1 to n do
If i mod 2 = 0 then write(i,' ');
Readln;
End.
uses crt;
var n,i:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if i mod 2=0 then write(i:4);
readln;
end.
Ủa bạn ngay chỗ var n i: integer có thể thay thế bằng longint ko
uses crt;
var i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
for i:=1 to n do
if i mod 2=0 then
begin
inc(dem);
write(i:4);
if dem=15 then writeln;
end;
readln;
end.
uses crt;
var i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if i mod 2=1 then write(i:4);
readln;
end.
Var n,i,so:integer;
Begin
Write('Nhap n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(so);
If so mod 2 = 0 then writeln(so);
End;
Readln;
End.
uses crt;
var n,i,o,d:integer;
function ktnt(n:integer): integer;
var i,d:integer;
begin
d:=0;
for i:=1 to sqrt(n) do
if (n mod i=0) then d:=d+1;
if d=2 then ktnt=0
else ktnt=1;
end;
begin
readln(n);
writeln(' so nguyen to be hon hoac bang n la'); {a}
for i:=1 to n do
if ktnt(i)=0 then writeln(i);
writeln('so nguyen to nho nhat khong be hon n');
o:=n;
while o>0 do
begin
if ktnt(o)=0 then
begin
write(o);
break;
end;
o:=o+1;
end;
writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');
o:=0;
o:=1;
d:=0;
for i:=o+2 to n do
begin
if ktnt(i)=0 then
begin
d:=d+1;
write(i,' ');
if d<2 then continue;
end;
d:=0;
writeln;
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
if (i%2==1) cout<<i<<" ";
return 0;
}
Program Tim_so_chan;
uses crt;
var i,n:integer;
Begin
clrscr;
Write('Nhap so n:'); Readln(n);
For i:=1 to n do If i mod 2=0 then Write('Cac so chan nho hon n la:' ,i:3,',');
Readln
End.
program dffg;
uses crt ;
var a,b,n:integer;
begin
write('a=');
readln(a);
write('b=');
readln(b);
for n:=a to b do if (n mod 2) = 0 then write(n);
readln;
end.