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.

12 tháng 1 2022

Viết câu lệnh thực hiện yêu cầu sau:

4. Với dữ liệu câu 2, yêu cầu tính và in ra màn hình:

4a. Tổng các số chẵn

4b. Đếm các số lẽ

4c. Tích các số chia hết cho 2 hoặc 3

 

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

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

else dem1+=1;

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

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

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

else dem1+=1;

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

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,t,dem;

int main()

{

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

t=0;

dem=0;

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

{

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

else dem++;

}

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

cout<<endl;

cout<<t<<endl;

cout<<dem;

return 0;

}

14 tháng 1 2022

hong đúng bạn ơi

Câu 1: 

a) var a:array[1..50]of real;

b) a[5]:=8;

c) for i:=1 to 50 do  

begin

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

end;

for i:=1 to 50 do 

 write(a[i]:4);

 

Câu 2: 

uses crt;

var s,i:integer;

begin

clrscr;

s:=0;

for i:=1 to 10 do 

  s:=s+i;

writeln(s);

readln;

end.

Tham khảo:

Giải bài tập Tin học 8 | Để học tốt Tin học 8

9 tháng 11 2021

Ghi ra được không ạ

14 tháng 12 2020

uses crt;

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

i,vtc,vtl:integer;

begin

clrscr;

for i:=1 to 5 do 

  begin

write('G[',i,']='); readln(g[i]);

end;

vtc:=0;

vtl:=0;

for i:=1 to 5 do 

  begin

if g[i] mod 2=0 then 

  begin

  if vtc<i then vtc:=i;

end

else begin

if vtl<i then vtl:=i;

end;

end;

writeln('Vi tri phan tu le cuoi cung la: ',vtl);

writeln('Vi tri phan tu chan cuoi cung la: ',vtc);

readln;

end. 

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

t2=0;

t3=0;

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

{

t1+=a[i];

if (a[i]<0) t2+=a[i];

if (a[i]>0) t3+=a[i];

}

cout<<t1<<endl;

cout<<t2<<endl;

cout<<t3;

return 0;

}

5 tháng 5 2022

Câu 1: Cú pháp khai báo mảng trong pascal:

Var <tên mảng>:array[1..n] of <kiểu dữ liệu>;

Cây 2: Khai báo mảng c gồm 20 phần tử kiểu số thực:

Var c:array[1..20] of real;