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 i,n,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
writeln(t);
readln;
end.
uses crt;
var i,n,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+i;
writeln(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.
uses crt;
var n, i, j, dem: longint; {Bạn có thể thay longint thành integer nha}
A:array[1..1000] of longint;
begin
clrscr;
Write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(A[i]);
end;
Write('Cac so nguyen to co trong mang la: ');
for i:=1 to n do
begin
dem:=0;
for j:=2 to A[i]/2 do
if A[i] mod j=0 then dem:=dem+1;
if dem=0 then write(A[i],'; ');
end;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(s);
readln;
end.
Câu 2:
uses crt;
var t,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
t:=t+i;
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) if (i%3==0) cout<<i<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..1000000] of longint;
n,i:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Cac so chan: ');
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
readln;
end.
program tim_so_nguyen;
uses crt;
var i,N:integer;
begin
clrscr;
write('nhap so nguyen:');
readln(N);
if N <= 2 then write(N,' khong phai la so nguyen to')
else
begin
i:=2;
while ( N mod i <> 0 ) do i:=i+1;
if i=N then write(N,' la so nguyen to')
else write(N,' khong phai la so nguyen to');
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,kt;
cin>>n;
for (int i=2; i<=n; i++)
{
kt=0;
for (int j=2; j*j<=i; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
}