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,b,vt:array[1..100]of integer;
n,i,dem,j,kt,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
b[1]:=a[1];
dem:=1;
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if b[j]=a[i] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to dem do
if b[i] mod 2<>0 then
begin
max:=0;
for j:=1 to n do
if b[i]=a[j] then
begin
if max<j then max:=j;
end;
writeln(b[i],' xuat hien o vi tri thu ',max);
end;
readln;
end.
#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,b,c:array[1..1000]of integer;
i,n,dem,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
for i:=1 to n do
if max=a[i] then
begin
inc(dem);
b[dem]:=a[i];
c[dem]:=i;
end;
if dem=1 then writeln('So lon nhat la: ',b[dem],' vi tri la: ',c[dem])
else writeln('So lon nhat la: ',b[1],' vi tri la: ',c[1]);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[40],i,n,ln;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
for (i=n; i>=1; i--)
if (ln==a[i])
{
cout<<i;
break;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,ln,x;
int main()
{
cin>>n>>x;
ln=x;
for (i=1; i<n; i++)
{
cin>>x;
ln=max(ln,x);
}
cout<<ln;
return 0;
}
$#include <bits/stdc++.h>
using namespace std;
long long n,i,ln,x;
int main()
{
cin>>n>>x;
ln=x;
for (i=1; i<n; i++)
{
cin>>x;
ln=max(ln,x);
}
cout<<ln;
return 0;
}$
uses crt;
var b,a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if b[i]<0 then inc(dem);
if b[i]>0 then inc(dem1);
end;
writeln('So phan tu am la: ',dem);
writeln('So phan tu duong la: ',dem1);
t:=0;
for i:=1 to n do
if b[i]<>0 then t:=t+b[i];
writeln('Trung binh cac phan tu khac 0 trong mang la: ',t/(dem+dem1):4:2);
min:=b[1];
for i:=1 to n do
if min>b[i] then min:=b[i];
dem2:=0;
for i:=1 to n do
if min=b[i] then
begin
inc(dem2);
a[dem2]:=i;
end;
writeln('Gia tri nho nhat la: ',min);
writeln('Chi so la: ');
for i:=1 to dem2 do
write(a[i]:4);
readln;
end.
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
tham khảo'
uses crt;
var a:array[1..100]of integer;
i,n,t,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('So luong so chan la: ',dem);
readln;
end.
Var a:array[1..100] of integer;
i,n,dem,vt,s sc,sl,min:integer;
tbc:real;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do s:=s+a[i];
tbc:=s/n;
Writeln('Gia tri trung binh cua mang la ',tbc:10:2);
Write('Cac phan tu lon hon gia tri trung binh la ');
For i:=1 to n do
If a[i]>tbc then write(a[i],' ');
For i:=1 to n do
Begin
If a[i] mod 2 = 0 then sc:=sc+a[i]
Else sl:=sl+a[i];
End;
Writeln('Tong cac phan tu chan la ',sc);
Writeln('Tong cac phan tu le la ',sl);
min:=a[1];
For i:=2 to n do
Begin
If a[i] < min then min:=a[i];
vt:=i;
End;
Writeln('Phan tu nho nhat la ',min,' tai vi tri ',vt);
For i:=1 to n do
If a[i] mod 5 = 0 then dem:=dem+1;
Write('So cac phan tu chia het cho 5 la ',dem);
Readln;
End.
#include<bits/stdc++.h>
using namespace std;
int a[1000000],n,b[1000000];
int main(){
cin >>n;
for (int i=1;i<=n;i++) {cin >> a[i];
if (a[i]%2==1) b[a[i]]=i;
}
for (int i=1;i<=n;i++){
if (b[a[i]]!=0) {cout << b[a[i]] << " "<<a[i]<<'\n';b[a[i]]=0;}
}
}
Nhập trực tiếp , in dạng :
Chỉ số _ số
......
Mình đang học pascal ạ