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;
const long long maxint=1e6;
long long a[maxint],i,n,ln;
int main()
{
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>a[i];
    ln=a[1];
    for (i=1; i<=n; i++)
        ln=max(ln,a[i]);
    for (i=n; i>=1; i--)
        if (ln==a[i])
    {
        cout<<i;
        break;
    }
    return 0;
}

 

#include <bits/stdc++.h>

using namespace std;

long long a[150],i,s,n,nn;

int main()

{

cin>>n;

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

s=1;

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

if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];

cout<<s<<endl;

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

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

if (nn==a[i]) 

{

cout<<i<<endl;

break;

}

sort(a+1,a+n+1);

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

return 0;

}

16 tháng 12 2022

#include <bits/stdc++.h>

using namespace std;

int A[500],n,i,dem,dem1;

int main()

{

cin>>n;

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

for (int i=n; i>=1; i--) cout<<A[i]<<" ";

cout<<endl;

dem=0;

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

if (A[i]<10) dem++;

cout<<dem<<endl;

dem1=0;

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

if (A[i]>1)

{

bool kt=true;

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

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

if (kt==true) dem1++;

}

cout<<dem1;

return 0;

}

uses crt;

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

i,n,dem,max:integer;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

dem:=0;

max:=a[1];

for i:=1 to n do 

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

for i:=1 to n do 

if max=a[i] then     

begin       

inc(dem);       

b[dem]:=a[i];       

c[dem]:=i;     

end;

if dem=1 then writeln('So lon nhat la: ',b[dem],' vi tri la: ',c[dem])

else writeln('So lon nhat la: ',b[1],' vi tri la: ',c[1]);

readln;

end.

25 tháng 2 2021

Bọn em học C++ ạ :<<

 

24 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

t=0;

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

{

cin>>a[i];

t=t+a[i];

}

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

cout<<endl;

dem=0;

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

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

cout<<dem<<endl;

cout<<t;

return 0;

}

uses crt;

var a:array[1..10]of longint;

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

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

20 tháng 1 2022

uses crt;

var a:array[1..10]of longint;

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

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

11 tháng 5 2022

tham khảo'

 

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('Tong cac so chan la: ',t);

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

readln;

end.

11 tháng 5 2022

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

i,n,dem,vt,s sc,sl,min:integer;

tbc:real;

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;

For i:=1 to n do s:=s+a[i];

tbc:=s/n;

Writeln('Gia tri trung binh cua mang la ',tbc:10:2);

Write('Cac phan tu lon hon gia tri trung binh la ');

For i:=1 to n do

If a[i]>tbc then write(a[i],'   ');

For i:=1 to n do

Begin

If a[i] mod 2 = 0 then sc:=sc+a[i]

Else sl:=sl+a[i];

End;

Writeln('Tong cac phan tu chan la ',sc);

Writeln('Tong cac phan tu le la ',sl);

min:=a[1];

For i:=2 to n do

Begin

If a[i] < min then min:=a[i];

vt:=i;

End;

Writeln('Phan tu nho nhat la ',min,' tai vi tri ',vt);

For i:=1 to n do

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

Write('So cac phan tu chia het cho 5 la ',dem);

Readln;

End.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

n=5;

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

cin>>a[i];

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

cout<<endl;

t=0;

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

cout<<t<<endl;

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

if (i%2!=0) cout<<a[i]<<" ";

return 0;

}