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;

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;

}

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;

}

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

freopen("dulieu.txt","r",stdin);

freopen("uot.txt","w",stdout);

cin>>n;

t=0;

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

if (i%2==0) t+=i;

cout<<t;

return 0;

}

14 tháng 3 2023

#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int a[32];
    int n,i,s;
    cout<<"nhap so phan tu cua mang ";
    cin>>n;
    cout<<"nhap cac phan tu cua mang ";
    for (i=1; i<=n; i++)
    {
        s=0;
        cin>>a[i];

    }
    for(i=1; i<=a[i]; i++) s=s+i;

    cout<<s;
    return 0;
}

 

 

14 tháng 3 2023

Program HOC24;

var i,n: integer;

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

t: longint;

begin

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

for i:=1 to n do

begin

write('Nhap so thu ',i,': '); readln(i);

end;

t:=0;

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

write('Tong la: ',t);

readln

end.

26 tháng 3 2022

var a:Array [1..100] of word;

      n,i:byte;

      S:word;

begin

 write('Nhap so so hang trong day : n = '); readln(n);

 for i:=1 to n do begin

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

                          readln(A[i]);

                         end;

S:=0;

for i:=1 to n do if A[i] mod 2 = 1 then S:=S+A[i];

if S = 0 then write('Trong day khong co so le nao nen khong tong khong ton tai') else write('Tong cac so le trong day la : S = ',S);

readln

end.

29 tháng 11 2021

Tham khảo

 

uses crt;

var n,i,ta,td,d1,d2:integer;

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

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

td:=0;

d1:=0;

for i:=1 to n do

if a[i]>0 then

begin

td:=td+a[i];

inc(d1);

end;

writeln('Trung binh cong cac so duong la: ',td/d1:4:2);

d2:=0;

ta:=0;

for i:=1 to n do

if a[i]<0 then

begin

inc(d2);

ta:=ta+a[i];

end;

writeln('Trung binh cong cac so am la: ',ta/d2:4:2);

readln;

end.

4 tháng 4 2022

MỌI NGƯỜI ƠI GIÚP EM VỚI Ạ EM CẢM ƠN NHIỀU LẮM Ạ 

Viết chương trình nhập vào dãy số nguyên có N phần tử. - Tính tổng các số lẽ. - Tính tích các số chẵn.

4 tháng 4 2022

Viết chương trình nhập vào dãy số nguyên có N phần tử. - Tính tổng các số lẽ. - Tính tích các số chẵn.

mọi người giúp em với em cảm ơn ạ

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,t1,t2;

int main()

{

cin>>n;

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

t1=0;

t2=1;

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

{

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

else t2*=a[i];

}

cout<<t1<<endl;

cout<<t2<<endl;

return 0;

}

1:

uses crt;

const fi='ketqua.txt';

var f1:text;

st:string;

i,d:integer;

begin

clrscr;

assign(f1,fi); rewrite(f1);

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

 if st[i]=#32 then delete(st,i,1);

writeln(f1,st);

close(f1);

end.

2:

uses crt;

var a,b,c,d:integer;

{----------chuong-trinh-con-----------------------}

function min(x,y:integer):integer;

begin

if x<y then min:=x

else min:=y;

end;

{---------------chuong-trinh-chinh--------------------}

begin

clrscr;

write('a='); readln(a);

write('b='); readln(b);

write('c='); readln(c);

write('d='); readln(d);

writeln(min(a,min(b,min(c,d))));

readln;

end.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

t=0;

dem=0;

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

{

cin>>x;

if (x%2==0)

{

dem++;

t+=x;

}

}

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

return 0;

}

21 tháng 1 2022

Ở free pascal ạ