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.
câu 1:
uses crt;
var p,i:integer;
begin
clrscr;
p:=1;i:=1;while i<=5 do
begin
p:=p*i;i:=i+1;
end;
write(p);
readln;
end.
bai 2:
uses crt;var p,i:integer;begin clrscr; p:=1; i:=0; while i <=10 do begin
i:=i+1; if (i mod 2<>0) then p:=p*i; end; write(p); readln;end. bai 3:
uses crt;var n,i,p:integer;begin clrscr; write('nhap n: '); readln(n); i:=1; p:=1; while i<=n do begin if i mod 2=0 then p:=p*i; i:=i+1; end; write(p); 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 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.
#include <bits/stdc++.h>
using namespace std;
long long t1,t2,i,n,x;
int main()
{
cin>>n;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) t1=t1+x;
else t2=t2+x;
}
cout<<t1<<" "<<t2;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,A[100],dem,t;
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
dem=0; t=0;
for (int i=1; i<=n; i++)
if (A[i]%2==0) dem++;
else t+=A[i];
cout<<dem<<endl;
cout<<t;
return 0;
}
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 m,n,t1,t2,i:integer;
begin
clrscr;
repeat
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
until m<=n;
t1:=0;
t2:=0;
for i:=m to n do
begin
if i mod 2=0 then t1:=t1+i
else t2:=t2+i;
end;
writeln('Tong cac so chan tu ',m,' den ',n,' la: ',t1);
writeln('Tong cac so le tu ',m,' den ',n,' la: ',t2);
readln;
end.