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.

28 tháng 3 2021

theo C++ nhé bạn

#include<bits/stdc++.h>

using namespace std;

int a[100],n,i;

int main()

{

cout<<"hay nhap so phan tu cua mang: ";     

cin>>n;

cout<<"hay nhap gia tri cac phan tu cua mang: ";   

for(i=1;i<=n;i++) cin>>a[i];

cout<<"gia tri cac phan tu trong mang la: ";

 for(i=1;i<=n;i++) cout<<a[i]<<" ";

return 0;

}

28 tháng 3 2021

program mang;

uses crt;

var n,i:integer;

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

begin

clrscr;

write('nhap so phan tu :');readln(n);

for i:=1 to n do

begin

write('nhap phan tu a[',i,']:');readln(n);

end;

for i:=1 to n do

write(a[i]:3);

readln;

end.

28 tháng 3 2021

10 tháng 5 2023

Bài 1

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

i,n:integer;

s:longint;

Begin

Repeat

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

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

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

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

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so chan la ',s);

Readln

End.

10 tháng 5 2023

Bài 2

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

i,n:integer;

s:longint;

Begin

Repeat

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

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

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

if a[i] mod 2 <> 0 then s:=s+a[i];

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so le la ',s);

Readln

End.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

if (t==a[i]) dem++;

}

cout<<dem<<endl;

t1=0;

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

if (a[i]%2==0) t1+=a[i];

cout<<t1;

return 0;

}

25 tháng 5 2022

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

if (t==a[i]) dem++;

}

cout<<dem<<endl;

t1=0;

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

if (a[i]%2==0) t1+=a[i];

cout<<t1;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

if (t==a[i]) dem++;

}

cout<<dem<<endl;

t1=0;

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

if (a[i]%2==0) t1+=a[i];

cout<<t1;

return 0;

}

uses crt;

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

i,n,k:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

for i:=1 to n do 

  if a[i] mod k=0 then write(a[i]:4);

readln;

end.

Bài 1: 

uses crt;

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

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if a[i]>a[j] then 

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln('Day tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

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

max:=0;

kt:=0;

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]<=x) then 

   begin

  if max<a[i] then max:=a[i];

kt:=1;

end;

if kt=0 then writeln('Trong day khong co so le')

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

20 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[10000];

int main()

{

cin>>n;

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

cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,A[100];

cin>>n;

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

cin>>A[i];

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

cout<<A[i]<<" ";

return 0;

}