Những câu hỏi liên quan
Hoan Lý
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 4:33

Câu 1:

var i,n:integer;

s:longint;

begin

Write('n = ');readln(n)

for i:=1 to n do

s:=s+2*i+1;

write('tong la: ',s);

readln

end.

Kiều Vũ Linh
10 tháng 5 2023 lúc 4:36

Câu 2

Bài 5:

Var b:array:[1..1000] of integer;

i,n,max:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(b[i]);

End;

Write('Cac phan tu am la: ');

For i:=1 to n dko

if b[i]<0 then write(b[i]:8);

writeln;

max:=b[1];

For i:=2 to n do

If b[i] > max then max:=b[i];

write('So lon nhat la ',max);

Readln

End.

Phan Văn Thái Dương
Xem chi tiết
Nguyen Thanh Tam
Xem chi tiết
HUY
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 12 2022 lúc 15:37

#include <bits/stdc++.h>

using namespace std;

int n,s,i,t;

int main()

{

freopen("bai1.inp","r",stdin);

freopen("bai1.out","w",stdout);

cin>>n>>s;

t=0;

for (int i=1; i<=n; i++)

{

int x;

cin>>x;

if (x%s==0) t+=x;

}

cout<<t;

}

Linh hoa
Xem chi tiết
Hải Nguyễn
Xem chi tiết
Lê Phương Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 21:55

uses crt;

var a:array[1..250]of integer;

i,n,dem,t,t1,t2,t3,t4:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (0<n) and (n<=250);

for i:=1 to n do 

  begin

repeat

write('A[',i,']='); readln(a[i]);

until (0<a[i]) and (a[i]<=500);

end;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=1 then inc(dem);

writeln('So phan tu co gia tri le la: ',dem);

t:=0;

for i:=1 to n do 

  if i mod 2=0 then t:=t+a[i];

writeln('Tong cac phan tu co chi so chan la: ',t);

t1:=0;

for i:=1 to n do 

  if i mod 2=1 then t1:=t1+a[i];

writeln('Tong cac phan tu co chi so le la: ',t1);

t2:=0;

for i:=1 to n do 

  if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];

writeln('Tong cac phan tu chan co chi so chan la: ',t2);

t3:=0;

for i:=1 to n do 

  if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];

writeln('Tong cac phan tu co chi so le la: ',t3);

t4:=0;

for i:=1 to n do 

  t4:=t4+a[i];

writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);

readln;

end.

Trần Nguyên
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 3 2021 lúc 20:20

uses crt;

var a:array[1..100]of integer;

n,i,s,max,k:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

max:=0;

for i:=1 to n do 

  for j:=1 to n do 

if i<=j then 

begin

s:=0;

for k:=i to j do 

  s:=s+a[k];

if max<s then max:=s;

end;

writeln(max);

readln;

end.

Jack Viet
Xem chi tiết