K
Khách

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.

9 tháng 5 2022

Var a:array[1..200] of integer;

i,n,dem:integer;

Begin

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

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

End;

dem:=0;

For i:=1 to n do

If a[i]>5 then dem:=dem+1;

Write('So phan tu lon hon 5 la ',dem);

Readln;

End.

19 tháng 4 2023

program TinhTongSo;
uses crt;
var
  a: array [1..10] of integer;
  i, tong, dem: integer;
begin
  clrscr;
  writeln('Nhap day 10 so nguyen: ');
  for i := 1 to 10 do
  begin
    write('Nhap so thu ', i, ': ');
    readln(a[i]);
  end;
  writeln('Day so da nhap tren mot hang: ');
  for i := 1 to 10 do
    write(a[i], ' ');
  tong := 0;
  for i := 1 to 10 do
    if a[i] < 0 then
      tong := tong + a[i];
  writeln('Tong cac so nguyen am: ', tong);
  dem := 0;
  for i := 1 to 10 do
    if (a[i] > 6) and (a[i] < 9) then
      dem := dem + 1;
  writeln('So luong cac so thoa dieu kien "lon hon 6 va nho hon 9": ', dem);
  readln;
end.

#include <iostream>
using namespace std;
int main()
{
    int a[100][100],i,j,m,n;
    cout<<"Nhap so dong cua mang:"; cin>>n;
    cout<<"Nhap so cot cua mang:"; cin>>m;
    for (i=1; i<=n; i++)
        for (j=1; j<=m; j++)
    {
        cout<<"A["<<i<<","<<j<<"]="; cin>>a[i][j];
    }
    for (i=1; i<=n; i++)
    {
        for (j=1; j<=m; j++)
            cout<<a[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}

 

uses crt;

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

i,n,dem,t:integer;

begin

clrscr;

repeat

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

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

for i:=1 to n do 

begin

repeat

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

until abs(a[i])<=1000;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do 

  if a[i]=0 then inc(dem);

writeln('So phan tu bang 0 la: ',dem);

t:=0;

for i:=1 to n do 

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

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

readln;

end. 

4 tháng 5 2023

program tinh_tong_va_dem_so_x;

const
  MAX = 100;

var
  a: array[1..MAX] of integer;
  n, tong, x, dem, i: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(n);
  for i := 1 to n do
  begin
    write('Nhap phan tu thu ', i, ': ');
    readln(a[i]);
  end;
  tong := 0;
  for i := 1 to n do
  begin
    tong := tong + a[i];
  end;
  writeln('Tong cac phan tu trong mang la: ', tong);
  write('Nhap gia tri x: ');
  readln(x);
  dem := 0;
  for i := 1 to n do
  begin
    if a[i] = x then
    begin
      dem := dem + 1;
    end;
  writeln('So lan xuat hien cua ', x, ' trong mang la: ', dem);
  readln;
end.

Câu 4: 

uses crt;

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

i,n,dem,t:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

  if (10<a[i]) and (a[i]<20) then 

begin

inc(dem);

t:=t+a[i];

end;

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

writeln('Tong cac phan tu lon hon 10 va nho hon 20 la: ',t);

readln;

end.

Câu 5:

uses crt;

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

i,n,dem,t:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

inc(dem);

t:=t+a[i];

end;

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

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

readln;

end.