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..100]of integer;
i,n,min,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
dem:=0;
for i:=1 to n do
if min=a[i] then inc(dem);
writeln('So phan tu co gia tri nho nhat la: ',dem);
readln;
end.
Bài 4:
Program hotrotinhoc_hoc24;
var i,n,k,d: integer;
a: array[1..32000] of integer;
begin
write('Nhap so phan tu : '); readln(n);
d:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('Nhap so nguyen k : '); readln(k);
for i:=1 to n do
if a[i]=k then inc(d);
if d>0 then writeln('So nguyen K xuat hien trong day') else writeln('So nguyen K khong xuat hien trong day');
write('So lan xuat hien cua k la :',d);
readln
end.
Bài 3:
Program hotrotinhoc_hoc24;
var i,n,max,min: integer;
a: array[1..32000] of integer;
begin
write('Nhap so phan tu : '); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=0; min:=32000;
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('Gia tri lon nhat la : ',max);
write('Thu tu xuat hien cua gia tri lon nhat la :');
for i:=1 to n do if a[i]=max then write(i,' ');
writeln;
writeln('Gia tri nho nhat la : ',min);
write('Thu tu xuat hien cua gia tri nho nhat la :');
for i:=1 to n do if a[i]=min then write(i,' ');
readln
end.
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,max: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];
for i:=1 to n do
if max<a[i] then max:=a[i];
t:=0;
for i:=1 to n do
if max=a[i] then t:=t+a[i];
writeln('Tong cac phan tu co gia tri lon nhat la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
#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;
}
1:
#include <bits/stdc++.h>
using namespace std;
long long t1,t2,i,n,x;
int main()
{
cin>>n;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0) t1=t1+x;
else t2=t2+x;
}
cout<<t1<<" "<<t2;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[150],i,s,n,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
s=1;
for (i=1; i<=n; i++)
if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];
cout<<s<<endl;
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
for (i=n; i>=1; i--)
if (nn==a[i])
{
cout<<i<<endl;
break;
}
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t,min,vt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 3 la: ',t);
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
vt:=1;
for i:=1 to n do
if min=a[i] then
begin
if vt<i then vt:=i;
end;
writeln('Gia tri nho nhat la: ',min);
writeln('Vi tri la: ',vt);
readln;
end.
uses crt;
var a,b:array[1..100]of real;
i,n,dem:integer;
max:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>0 then
begin
inc(dem);
b[dem]:=a[i];
end;
if dem=0 then writeln('1')
else begin
max:=b[1];
for i:=1 to dem do
if max<b[i] then max:=b[i];
writeln(max:4:2);
end;
readln;
end.
Hãy tìm giá trị dương nhỏ nhất trong mảng 1 chiều các số thực nếu mảng không có giá trị dương thì