a) S1= 1+2+3+…+365 b) S2= 1+3+5+…+365 c) S3= 2+4+6+…+364 d)S4= 1^2+2^2+3^2+…+365^2 (Pascal,cấu trúc lặp) 24/07/2021 Bởi Claire a) S1= 1+2+3+…+365 b) S2= 1+3+5+…+365 c) S3= 2+4+6+…+364 d)S4= 1^2+2^2+3^2+…+365^2 (Pascal,cấu trúc lặp)
Cái này mình làm thành 1 bài luôn nha, 4 câu a,b,c,d program tong; var i,S1,S2,S3,S4:longint; begin S1:=0; S2:=0; S3:=0; S4:=0; for i:=1 to 365 do begin S1:=S1+i; if i mod 2<>0 then S2:=S2+i else S3:=S3+i; S4:=S4+i*i; end; writeln(‘a) ‘,S1); writeln(‘b) ‘,S2); writeln(‘c) ‘,S3); writeln(‘d) ‘,S4); readln; end. Bình luận
bài chung program tinhtong; var i,s1,s2,s3:integer; s4:longint; begin clrscr; s1:=0; s2:=0; s3:=0; s4:=0; for i:=1 to 365 do begin s1:=s1+i; if i mod 2=1 then s2:=s2+i; if i mod 2=0 then s3:=s3+i; s4:=s4+i*i; end; writeln(‘S1= ‘,s1); writeln(‘S2= ‘,s2); writeln(‘S3= ‘,s3); writeln(‘S4= ‘,s4); readln end. bài 1: program tinhtong; uses crt; var i,t:integer; begin clrscr; t:=0; for i:=1 to 365 do t:=t+i; write(‘tong la: ‘,t); readln end. Bài 2: program tinhtong; uses crt; var i,t:integer; begin clrscr; t:=0; for i:=1 to 365 do if i mod 2=1 then t:=t+i; writeln(‘Tong la: ‘,t); readln end. bài 3: program tinhtong; uses crt; var i,t:integer; begin clrscr; t:=0; for 2:=1 to 364 do if i mod 2=0 then t:=t+i; writeln(‘Tong la: ‘,t); readln end. bài 4: program tintong; uses crt; var i:integer; t:longint; begin clrscr; t:=0; for i:=1 to 365 do t:=t+i*i; write(‘tong la: ‘,t); readln end. Bình luận
Cái này mình làm thành 1 bài luôn nha, 4 câu a,b,c,d
program tong;
var
i,S1,S2,S3,S4:longint;
begin
S1:=0; S2:=0; S3:=0; S4:=0;
for i:=1 to 365 do
begin
S1:=S1+i;
if i mod 2<>0 then S2:=S2+i else S3:=S3+i;
S4:=S4+i*i;
end;
writeln(‘a) ‘,S1);
writeln(‘b) ‘,S2);
writeln(‘c) ‘,S3);
writeln(‘d) ‘,S4);
readln;
end.
bài chung
program tinhtong;
var i,s1,s2,s3:integer;
s4:longint;
begin
clrscr;
s1:=0; s2:=0; s3:=0; s4:=0;
for i:=1 to 365 do
begin
s1:=s1+i;
if i mod 2=1 then s2:=s2+i;
if i mod 2=0 then s3:=s3+i;
s4:=s4+i*i;
end;
writeln(‘S1= ‘,s1);
writeln(‘S2= ‘,s2);
writeln(‘S3= ‘,s3);
writeln(‘S4= ‘,s4);
readln
end.
bài 1:
program tinhtong;
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 365 do
t:=t+i;
write(‘tong la: ‘,t);
readln
end.
Bài 2:
program tinhtong;
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 365 do
if i mod 2=1 then t:=t+i;
writeln(‘Tong la: ‘,t);
readln
end.
bài 3:
program tinhtong;
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for 2:=1 to 364 do
if i mod 2=0 then t:=t+i;
writeln(‘Tong la: ‘,t);
readln
end.
bài 4:
program tintong;
uses crt;
var i:integer;
t:longint;
begin
clrscr;
t:=0;
for i:=1 to 365 do
t:=t+i*i;
write(‘tong la: ‘,t);
readln
end.