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;
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;
}
uses crt;
var n,t1:integer;
s:real;
begin
clrscr;
t1:=0;
s:=1;
repeat
readln\(\left(n\right)\);
if n mod 2=0 then t1:=t1+n
else s:=s*n;
until n=0;
writeln\(\left(t1\right)\);
writeln\(\left(s:4:2\right)\);
readln;
end.
uses crt;
var a,t:integer;
begin
clrscr;
t:=0;
repeat
write('Nhap a='); readln(a);
t:=t+a;
until a=0;
writeln(t);
readln;
end.
program timtich;
uses crt;
var i,n:integer;
tich:longint;
a:array[1..100]of integer;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
tich:=1;
writeln;
for i:=1 to n do
if a[i] mod 2=0 then tich:=tich*a[i];
writeln('tich ca phan tu chan cua mang la:',tich);
readln;
end.
program timtong;
uses crt;
var i,n:integer;
tong:longint;
a:array[1..100]of integer;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
tong:=0;
writeln;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cac phan tu chan cua mang la:',tong);
tong:=0;
writeln;
for i:=1 to n do
if a[i] mod 2=1 then tong:=tong+a[i];
writeln('tong cac phan tu le cua mang la:',tong);
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
s:=1;
for i:=1 to n do
if a[i] mod 2=0 then s:=s*a[i];
writeln(s);
readln;
end.
uses crt;
var a,t:integer;
begin
clrscr;
t=0;
repeat
readln(a);
if (a>0) then t:=t+a;
until (a mod 2=0);
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,dem1,dem2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem1++;
else dem2++;
}
cout<<"So so chan la: "<<dem1<<endl;
cout<<"So so le la: "<<dem2;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a;
int main()
{
cin>>a;
if (a%2==0) cout<<a<<" la so chan";
else cout<<a<<" la so le";
return 0;
}
a)
uses crt;
var i,n:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n<100;
if n mod 2=0 then
begin
for i:=0 to n do
if i mod 2=0 then write(i:4);
end
else writeln(n,' khong la so chan');
readln;
end.
b)
uses crt;
var i,n:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n<100;
if n mod 2=1 then
begin
for i:=1 to n do
if i mod 2=1 then write(i:4);
end
else writeln(n,' khong la so le');
readln;
end.
Program HOC24;
var i,n: integer;
t: longint;
begin
write('Nhap so: ');
readln(n);
if n mod 2=0 then t:=n else t:=0;
while n<>0 do
begin
write('Nhap so: ');
readln(n);
if n mod 2=0 then t:=t+n;
end;
write('Ket qua la: ',t);
readln
end.