Những câu hỏi liên quan
❤X༙L༙R༙8❤
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 5 2021 lúc 10:49

Câu 2: 

a) Mô tả thuật toán

-Bước 1: Nhập n và nhập dãy số

-Bước 2: dem←0; i←1; t←0;

-Bước 3: Nếu a[i] mod 2=0 thì dem←dem+1 và t←t+a[i];

-Bước 4: i←i+1;

-Bước 5: Nếu i<=n thì quay lại bước 3

-Bước 6: Xuất t và dem

-Bước 7: Kết thúc

Bình luận (0)
Nguyễn Lê Phước Thịnh
15 tháng 5 2021 lúc 10:49

Câu 2: 

b) uses crt;

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

i,n,t,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

t:=0;

dem:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

t:=t+a[i];

inc(dem);

end;

writeln('So so chan la: ',dem);

writeln('Tong cac so chan la: ',t);

readln;

end.

Bình luận (0)
Quỳnh
Xem chi tiết
Minh Lệ
29 tháng 4 2021 lúc 14:33

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap N: ');

for i:=1 to n do

begin

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

end;

write('Day vua nhap la: '); 

for i:=1 to n do write(a[i],' '); writeln;

d:=0;

for i:=1 to n do if a[i]>0 then d:=d+1;

write('Co ',d,' so duong');

readln

end.

Bình luận (0)
Phan Thu
Xem chi tiết
Võ Phan Xuân Trung
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2022 lúc 20:20

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,dem;

int main()

{

cin>>n;

dem=0;

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

{

cin>>x;

if (x%2==0) dem++;

}

cout<<dem;

return 0;

}

Bình luận (0)
Hiền Nguyễn
Xem chi tiết
Hiền Nguyễn
24 tháng 3 2021 lúc 9:08

Bạn ơi giúp mình với chiều nay mình thi rồi

 

Bình luận (0)
Nguyễn Lê Phước Thịnh
24 tháng 3 2021 lúc 20:16

Câu 2: 

uses crt;

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

i,n,tb:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

tb:=0;

for i:=1 to n do 

  tb:=tb+a[i];

writeln(tb/n:4:2);

readln;

end.

Bình luận (0)
Tuoi tom May
Xem chi tiết
tiến bộc phấ
Xem chi tiết
NTKL
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 1 2022 lúc 10:13

Bài 2: 

#include <bits/stdc++.h>

using namespace std;

string st;

int d;

int main()

{

getline(cin,st);

d=st.length();

cout<<d;

return 0;

}

Bình luận (0)
Kiều Vũ Linh
19 tháng 1 2022 lúc 8:59

Bài 1:

Var so,i,n,dem:integer;

Begin

Write('Nhap so luong so n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i);readln(so);

If so mod 2 = 0 then dem:=dem+1;

End;

Write('Co ',dem,' so chan');

Readln;

End.

Bài 2:

Var st:string;

Begin

Write('Nhap vao xau ki tu ');readln(st);

Write(' Xau vua nhap co do dai la ',length(st));

Readln;

End.

Bình luận (0)
Sarah Lilia
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 20:53

uses crt;

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

i,n,dem,dem1,dem2,t:integer;

s:real;

begin

clrscr;

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

for i:=1 to n do 

begin

repeat

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

until a[i]>0;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do

  if a[i]>10 then inc(dem);

writeln('So phan tu lon hon 10 la: ',dem);

dem1:=0;

dem2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then inc(dem1)

else inc(dem2);

end;

writeln('So luong so chan la: ',dem1);

writeln('So luong so le la: ',dem2);

t:=0;

s:=1;

for i:=1 to n do 

  begin

if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];

if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];

end;

writeln('Tong cac so o vi tri chan co gia tri le la: ',t);

writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

writeln('Cac so chan va lon hon 10 la: ');

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);

readln;

end.

Bình luận (1)
huyền trang phan thị
Xem chi tiết
Ngô Bá Hùng
25 tháng 4 2023 lúc 23:20

program Tinh_Day_So;
var
  n, i, x, dem: integer;
  max, a: integer;
begin
  write('Nhập số ptử của dãy: ');
  readln(n);
  writeln('Nhập các ptu của dãy:');
  for i := 1 to n do
  begin
    readln(x);
    a := a + x;  
    if x mod 2 = 0 then
      dem := dem + 1; 
    if x > max then
      max := x; 
  end;
  writeln('Tổng dãy là: ', a);
  writeln('Số ptu chẵn là: ', dem);
  writeln('Gtln của dãy là: ', max);
end.

Bình luận (0)