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.
refer
uses crt;
var a:array[1..100]of integer;
n,i,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Vi tri cua so lon nhat la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
writeln('Vi tri cua so nho nhat la: ');
for i:=1 to n do
if min=a[i] then write(i:4);
readln;
program TimSoLonNhatVaDemSoAm;
var
N, i, max, dem: integer;
a: array[1..100] of integer;
begin
writeln('Nhap so ptu cua day: ');
readln(N);
for i := 1 to N do
begin
write('Nhap ptu thu ', i, ': ');
readln(a[i]);
end;
max := a[1];
for i := 2 to N do
begin
if a[i] > max then
max := a[i];
end;
writeln('So lon nhat trong day la: ', max);
dem := 0;
for i := 1 to N do
begin
if a[i] < 0 then
dem := dem + 1;
end;
writeln('So ptu am trong day la: ', dem);
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
kt:=0;
for j:=2 to trunc(sqrt(t)) do
if t mod j=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
readln;
end.
Cậu ơi sai khúc write('A[',i,']='); readln(a[i]); rồi nó cứ bị sao sao á
uses crt;
var a:array[1..100]of integer;
i,n,t,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac so vua nhap la: ',t);
if t>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
end
else writeln(t,' khong la so nguyen to');
readln;
end.
Bạn Akai làm thiếu rồi, mình xin bổ sung một chút cho nó hoàn thiện bài nhé:
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2,t3: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]:4);
writeln;
t1:=0;
t2:=0;
t3:=0;
for i:=1 to n do
begin
if a[i]>0 then t1:=t1+a[i];
if a[i] mod 2<>0 then t2:=t2+a[i];
if a[i] mod 2=0 then t3:=t3+a[i];
end;
writeln('Tong cac so duong la: ',t1);
writeln('Tong cac so le la: ',t2);
writeln('Tong cac so chan la: ',t3);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],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++)
{
t1+=a[i];
t2*=a[i];
}
cout<<t1<<" "<<t2;
return 0;
}
Program HOC24;
var i,n: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 2=0 then t:=t+a[i];
write('Tong cac so chan la: ',t);
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;
}