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.

#include <bits/stdc++.h>;
using namespace std;
int main()
{
    long i,n;
    float tbc,dem,t,a[10000];
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    dem=0;
    t=0;
    for (i=1; i<=n; i++)
        if (a[i]<0)
    {
        dem=dem+1;
        t=t+a[i];
    }
    tbc=t/dem;
    cout<<fixed<< setprecision(2)<<tbc;
    return 0;
}

 

12 tháng 5 2021

program du_lieu;

uses crt;

var i,n:integer;

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

tbc:real;

f:text;

begin

clrscr;

assign(f,'DULIEU.INP');reset(f);

readln(f,n);

for i:=1 to n do

begin

read(f,a[i]);

end;

close(f);

for i:=1 to n do

tbc:=tbc+a[i];

writeln(tbc/n);

readln;

end.

#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],i,n,j;

bool kt;

int main()

{

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

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

cin>>n;

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

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

if (a[i]>1) 

{

kt=true;

for (j=2; j*j<=a[i]; j++)

if (a[i]%j==0) kt=false;

if (kt==true) cout<<a[i]<<" ";

}

return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main()

{

long a[105], i,n,max,vt;

cout<<"n="; cin>>n;

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

{

cout<<"A["<<i<<"]="; cin>>a[i];

}

max=a[1];

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

if (max<a[i]) max=a[i];

vt=1;

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

if (max==a[i]) vt=i;

cout<<max<<endl;

cout<<vt;

return 0;

}

 

10 tháng 10 2022

bài này sai r bạn ơi

 

#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;

}

24 tháng 4 2023

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

i,n:integer;

s:longint;

Begin

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

For i:=1 to n do

Begin

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

s:=s+a[i];

End;

Write('Cac phan tu vua nhap la ');

For i:=1 to n do

Write(a[i]:8);

Writeln;

Write('Tong cua chung la ',s);

Readln

End.

uses crt;

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

i,n,max,dem: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 

  write(a[i]:4);

writeln;

max:=a[1];

for i:=1 to n do 

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

writeln('So lon nhat la: ',max);

write('Vi tri cua so lon nhat la: ');

for i:=1 to n do 

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

writeln;

dem:=0;

for i:=1 to n do 

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

writeln('So luong phan tu lon nhat trong day la: ',dem);

readln;

end. 

7 tháng 6 2021

uses crt;
var a:array[1..100000000] of int64;
      n,i,d,max:longint;
begin
        clrscr;
        repeat
                write('Nhap so luong phan tu: '); readln(n);
                if (n<=0) and (n>688886) then writeln('NHAP LAI!');
        until (n>0) and (n<=688886);
        for i:=1 to n do
                begin
                        write('Nhap phan tu thu ',i,': '); readln(a[i]);
                end;
        write('Day so vua nhap: ');
        for i:=1 to n do write(a[i],' ');
        max:=a[1];
        for i:=1 to n do if a[i]>max then max:=a[i];
        writeln;
        writeln('So lon nhat: ',max);
        write('Vi tri cua cac so lon nhat: ');
        for i:=1 to n do if a[i]=max then begin write(i,' '); inc(d) end;
        writeln;
        writeln('So luong so lon nhat: ',d);
        readln;
end.