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.
program tong_for_to_do;
uses crt;
var i,n:integer;
t:real;
begin
clrscr;
write('nhap n:');readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+1/i;
writeln('tong la: ',t);
readln;
end.
program tong_while_do;
uses crt;
var i,n:integer;
t:real;
begin
clrscr;
write('nhap n:');readln(n);
t:=0;i:=3;
while i<=3*n do
begin
t:=t+1/i;
i:=i+3;
end;
writeln('tong la: ',t);
readln;
end.
Program HOC24;
var i,n: integer;
S,P: longint;
begin
write('Nhap n: '); readln(n);
{..............................................}
readln
end.
-----------------------------------------------------------
Bạn điền vào {........................} theo từng bài nhé
a) S:=0;
for i:=1 to N do if i mod 2=1 then s:=s+i;
write('S= ',s);
b)
S:=0;
for i:=1 to N do if i mod 2=0 then s:=s+i;
write('S= ',s);
c) P:=1;
for i:=1 to N do if i mod 2=0 then p:=p*i;
write('P= ',p);
d)
P:=1;
for i:=1 to N do if i mod 2=1 then p:=p*i;
write('P= ',p);
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2!=0) t+=i;
cout<<t;
return 0;
}
For...do:
var s,i: integer;
begin
readln(s,i);
s:=0;
For i:=3 to 99 do
If i mod 3 = 0 do s:=s+i;
write(s)
readln;
end.
while ... do:
Var i,S:integer;
Begin
Readln(i,s);
S:=0;
i:=3;
while i<=99 do
if i mod 3 = 0 then s:=s+i;
write(s);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t=0;
cin>>n;
for (int i=1; i<=n; i++)
if (i%6==0) t+=i;
cout<<t;
return 0;
}
Var s1,s2,i,j:integer;
Begin
s1:=1;
s2:=0;
i:=2;
j:=4;
While i<=50 do
Begin
s1:=s1+i;
i:=i+2;
End;
While j<=20 do
Begin
s2:=s2+j;
j:=j+4;
End;
s2:=s2+32;
Writeln('Tong day N = ',s1);
Writeln('Tong day M = ',s2);
Readln;
End.
Uses Crt;
Var A : array [1..1000] of longint;
n, m, d, t, i, S, k : longint;
Begin
//Phan A
Clrscr;
Writeln(' Phan A ');
Write(' Ban hay nhap 1 so n bat ky: ');
Readln(n);
Write(' Cac so chia het cho ba tu 1 den ',n,' la: ');
For i:=1 to n do
If (i mod 3) = 0 then Write(' ',i);
//Phan B
Writeln;
Writeln(' Phan B ');
Write(' Ban hay nhap 1 so m bat ky: ');
Readln(m);
For i:=1 to m do
Begin
Write(' Ban hay nhap hang tu thu ',i,': ');
Readln(A[i]);
S:= S+A[i];
End;
Write(' Tong cua day so tren la: ',S);
//Phan C
Writeln;
Writeln(' Phan C ');
Write(' Ban hay nhap 1 so d bat ky: ');
Readln(d);
Write(' Ban hay nhap so K: ');
Readln(k);
For i:=1 to n do
Begin
Write(' Ban hay nhap hang tu thu ',i,': ');
Readln(A[i]);
If ((A[i] div k)=1)then t:=t+1;
End;
Write(' Co tat ca ',t,' so giong ',k);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t+=i;
cout<<t;
return 0;
}
*B=2+4+6+...+2020
uses crt;
var b:real;
i:integer;
begin
clrscr;
b:=0;
i:=0;
while i<=2020 do
begin
i:=i+2;
b:=b+i;
end;
writeln(b:0:0);
readln;
end.
*C=1/3+1/6+1/9+...+1/3n
uses crt;
var c:real;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
c:=0;
i:=1;
while i<=n do
begin
c:=c+1/(3*i);
i:=i+1;
end;
writeln(c:4:2);
readln;
end.