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.
Bài 1:
uses crt;
var n,i,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t1:=0;
for i:=1 to n do
t1:=t1+i*(i+1)*(i+2);
t2:=0;
for i:=1 to n do
begin
if i mod 2<>0 then t2:=t2+i*(i+1)*(i+2)
else t2:=t2-i*(i+1)*(i+2);
end;
writeln('T1=',t1);
writeln('T2=',t2);
readln;
end.
Bài 2:
uses crt;
var i,dem,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
writeln('Cac uoc cua mot so ',n,' la: ');
for i:=1 to n do
if n mod i=0 then
begin
write(i:4);
dem:=dem+1;
end;
writeln;
writeln('So luong uoc cua ',n,' la: ',dem);
readln;
end.
Uses crt;
var i,n,x: integer;
begin clrscr;
readln(n);
for i:=1 to n do x:=x*i;
writeln(x);
readln;
end.
Tham khảo :
Writeln('16 div 3=', 16 div 3);
Writeln('15 mod 3=', 15 mod 3);
Writeln('1.2+1.2.3+1.2.3.4=',1*2+1*2*3+1*2*3*4);
program TinhTong;
uses crt;
var
N, i, j, tich: integer;
S: real;
begin
clrscr;
write('Nhap so nguyen N: ');
readln(N);
S := 0;
tich := 1;
for i := 1 to N do
begin
tich := tich * i;
S := S + tich;
end;
writeln('Tong S = ', S:0:2);
readln;
end.
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 100 do s:=s+i;
writeln(s);
readln;
end.
#include <iostream>
using namespace std;
int main () {
int tong = 0;
for (int i = 1 ; i <= 100; i++) tong = tong + i;
cout << " Tong S = " << tong;
return 0;
}
Chạy chương trìnhTong S = 5050
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.
Câu 1:
var i,n:integer;
s:longint;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do
s:=s+(i*10+2);
write('S = ',s);
readln;
end.
Câu 2:
var i,n:integer;
s:real;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do s:=s+1/n;
write('tong la ',s:10:2);
readln;
end.
program tinh_tong ;
var i: integer; S: longint;
begin
S:= 0;
for i:= 1 to 98 do S:= S + i*(i+1)*(i+2);
writeln (' tong S la: ', S);
readln;
end.
program tinh tong ;
Var S,t: integer;
Begin
S:= 0;
For i:= 1 to 100 S:= S + i;
writeln (' tong cac so tu nhien tu 1 den 100');
Readln
End.