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.
uses crt;
var a:array[1..6]of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to 6 do
if a[i]>0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
program mang;
uses crt;
var n,i:integer;
a:array[1..100]of integer;
begin
clrscr;
write('nhap so phan tu :');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(n);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
theo C++ nhé bạn
#include<bits/stdc++.h>
using namespace std;
int a[100],n,i;
int main()
{
cout<<"hay nhap so phan tu cua mang: ";
cin>>n;
cout<<"hay nhap gia tri cac phan tu cua mang: ";
for(i=1;i<=n;i++) cin>>a[i];
cout<<"gia tri cac phan tu trong mang la: ";
for(i=1;i<=n;i++) cout<<a[i]<<" ";
return 0;
}
phần đọc tự viết
for i:=j to n do
b[i+1]:=a[i];
for i:=1 to j do write(g,a[i]);
write(g,M);
for i:=j+1 to n+1 do
write(g,b[i]);
uses crt;
var a,b:array[1..100]of integer;
i,n,m,k,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:6);
writeln;
write('Nhap m='); readln(m);
write('Nhap chi so k='); readln(k);
for i:=1 to k do
b[i]:=a[i];
for i:=k+2 to n+1 do
b[i]:=a[i-1];
b[k+1]:=m;
for i:=1 to n+1 do
write(b[i]:6);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int B[100],i,n,t=0,s=1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>B[i];
for (int i=1; i<=n; i++)
{
if (i%2==0) s*=A[i];
else t+=A[i];
}
cout<<t<<" "<<s;
}
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;
}
uses crt;
var a:array[1..10]of integer;
i,dem,dem1:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------xu-ly----------------------------}
dem:=0;
dem1:=0;
for i:=1 to 10 do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod 2=1 then inc(dem1);
end;
writeln('so phan tu chan trong day la: ,dem);
writeln('so phan tu le trong day la: ',dem1);
readln;
end.