Những câu hỏi liên quan
Trần Thị Thèo Lèo
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 3 2022 lúc 23:13

#include <bits/stdc++.h>

using namespace std;

long long b[5],i,n,k,dem,kt;

int main()

{

n=5;

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

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

cout<<endl;

dem=0;

for (i=1; i<=n; i++) if (b[i]%2==0) dem++;

cout<<"So so chan la: "<<dem<<endl;

cin>>k;

kt=0;

for (i=1; i<=n; i++) if (b[i]==k) 

{

cout<<i<<" ";

kt=1;

}

if (kt==0) cout<<"Khong co k trong day";

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

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

return 0;

}

Bình luận (1)
Trần Thị Thèo Lèo
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2022 lúc 12:51

uses crt;

var b:array[1..5]of integer;

i,n,dem,k,tam,j:integer;

kt:boolean;

begin

clrscr;

n:=5;

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

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

writeln;

dem:=0;

for i:=1 to n do if b[i] mod 2=0 then dem:=dem+1;

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

readln(k);

kt:=false;

for i:=1 to n do 

if b[i]=k then

begin

write(i:4);

kt:=true;

end;

if (kt==false) then writeln('Khong co k trong day')

else writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if b[i]>b[j] then 

begin

tam:=b[i];

b[i]:=b[j];

b[j]:=tam;

end;

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

readln;

end.

Bình luận (1)
Không tên
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2022 lúc 22:42

#include <bits/stdc++.h>

using namespace std;

long long b[15],i,n,k,dem;

bool kt;

int main()

{

n=15;

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

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

cout<<endl;

dem=0;

for (i=1; i<=n; i++) if (b[i]%2==0) dem++;

cout<<"So so chan la: "<<dem<<endl;

cin>>k;

kt=false;

for (i=1; i<=n; i++) if (b[i]==k) 

{

cout<<i<<" ";

kt=true;

}

if (kt==false) cout<<"Khong co k trong day";

else cout<<endl;

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

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

return 0;

}

Bình luận (0)
Kien
Xem chi tiết
Khánh Mỹ
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 1 2021 lúc 8:35

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

dem:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then 

begin

kt:=1;

break;

end;

if kt=0 then inc(dem);

end;

writeln('So phan tu la so nguyen to la: ',dem);

readln;

end.

Bình luận (1)
Benny
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 3 2023 lúc 14:55

6:

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,A[100],i,dem=0;

cin>>n;

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

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

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

cout<<dem;

return 0;

}

5:

#include <bits/stdc++.h>

using namespace std;

int main()

{

long long n,nn=1e6,A[1000];

cin>>n;

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

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

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

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

if (nn==A[i]) cout<<i<<" ";

return 0;

}

Bình luận (0)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:09

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.

Bình luận (0)
zero
20 tháng 1 2022 lúc 14:08

B

Bình luận (1)
Chanh Xanh
20 tháng 1 2022 lúc 14:08
Bình luận (1)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:08

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.

Bình luận (0)