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.

uses crt;

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

i,n:integer;

begin

clrscr;

randomize;

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

for i:=1 to n do 

a[i]:=random(100);

for i:=1 to n do 

 write(a[i]:4);

readln;

end.

Câu 7:

const fi='dayso.inp';

fo='dayso.out';

var f1,f2:text;

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

i,n,dem,j,t,kt,dem1:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,'Tong cua day so la: ',t);

b[1]:=a[1];

dem:=1;

for i:=1 to n do 

  begin

kt:=0;

for j:=1 to dem do 

  if a[i]=b[j] then kt:=1;

if kt=0 then

begin

inc(dem);

b[dem]:=a[i];

end;

end;

for i:=1 to dem do 

  begin

dem1:=0;

for j:=1 to n do 

  if b[i]=a[j] then inc(dem1);

writeln(f2,b[i],' xuat hien ',dem1,' lan');

close(f1);

close(f2);

end.

2:

#include <bits/stdc++.h>

using namespace std;

int A[100],ln,nn,vt1,vt2,n;

int main()

{

cin>>n;

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

ln=A[1];

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

ln=max(ln,A[i]);

nn=A[1];

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

nn=min(nn,A[i]);

vt1=1; vt2=n;

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

if (ln==A[i] && vt1<=i) vt1=i;

for (int i=n; i>=1; i--)

if (nn==A[i] && vt2>=i) vt2=i;

swap(A[vt1],A[vt2]);

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

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

}

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n,t;

int main()

{

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

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

cin>>n;

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

t=0;

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

cout<<fixed<<setprecision(1)<<(t*1.0)/(n*1.0);

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

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

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

cin>>n;

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

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

if (a[i]>0) cout<<a[i]<<" ";

return 0;

}

uses crt;

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

i,n,j,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do 

  if a[i]>1 then

begin

kt:=0;

for j:=2 to a[i]-1 do 

 if a[i] mod j=0 then kt:=1;

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

end;

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[100],i,n,x,dem;

int main()

{

cin>>n;

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

cin>>x;

dem=0;

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

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

cout<<dem;

return 0;

}

18 tháng 4 2022

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

i,n,dem:integer;

begin

write('Nhap so luong so N = ');readln(n);

for i:=1 to n do

begin

write('Nhap vao so thu ',i,': ');readln(a[i]);

if a[i] mod 3 = 0 then dem:=dem+1;

end;

write('Co ',dem,' so chia het cho 3');

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,dem;

int main()

{

cin>>n;

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

dem=0;

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

if (a[i]%3==0) dem++;

cout<<dem;

return 0;

}