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.

6 tháng 2 2022

Chương trình nhập n và mảng hay nhập mảng chưa biết số hạng tử v

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,ln,t1,dem,s;

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]);

cout<<ln<<endl;

t=0;

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

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]<0) dem++;

cout<<dem<<" ";

s=1;

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

if ((a[i]%3==0) and (a[i]>0)) s=s*a[i];

cout<<s;

return 0;

}

21 tháng 1 2022

viết chương trình chứ không phải chọn đáp án 

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

int main()

{

cin>>n;

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++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

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

cout<<dem<<" ";

t1=0;

dem1=0;

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

if (a[i]%2!=0)

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

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

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

return 0;

}

22 tháng 3 2022

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

      i,n,S,d:byte;

 begin

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

  for i:=1 to n do begin

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

                           readln(A[i]);

                          end;

d:=0; S:=0;

for i:=1 to n do if A[i] mod 2 = 0 then begin

                                                          d:=d+1;

                                                           S:=S+A[i];

                                                           end;

write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);

readln

end.

                                                          

                      

  

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

cin>>n;

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

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

cout<<endl;

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

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

cout<<endl;

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

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

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

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

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

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

return 0;

}

24 tháng 12 2021

Đề thiếu rồi bạn

3 tháng 4 2022

uses crt;

var C : array [1 .. 50] of integer;

i, n : integer;

begin

clrscr;

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

write('Nhap day gom ', n ,' so : ');

for i := 1 to n do read(C[i]);

write('Cac gia tri chan : ');

for i := 1 to n do

if C[i] mod 2 = 0 then write(C[i], ' ');

readln

end.

 

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n;

int main()

{

cin>>n;

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++) if (a[i]%2==0) t+=a[i];

cout<<"Tong cac so chan la: "<<t<<endl;

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

cout<<"Day so giam dan la: ";

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

return 0;

}

25 tháng 2 2022

Nhưng mà cái này dùng theo pascal và theo kiểu mảng ạ

17 tháng 12 2022

var n,i,dem,t:integer;
a:array[1..50] of integer;
begin
    dem:=0;
    t:=0;
    read(n);
    for i:=1 to n do 
    read(a[i]);
    for i:=n downto 1 do
    write(a[i]);
    writeln;
    for i:=1 to n do 
    if (a[i] mod 2 = 0) then dem:=dem+1;
    if a[i]<a[i-1] then t:=t+1;
    writeln(dem);
    if t=0 then write('Co lap thanh cap so +')
    else write('Ko the lap thanh cap so +');
    readln;
end.