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,x,y:integer;
//chuongtrinhcon
function ucln(var a,b:integer):integer;
var r:integer;
begin
while b>0 do
begin
r:=a mod b;
a:=b;
b:=r;
end;
ucln:=a;
end;
//chuongtrinhchinh
begin
clrscr;
readln(a,b);
x:=a;
y:=b;
if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));
if (x<0) and (y<0) then
begin
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
if (x<0) and (y>0) then
begin
write('-');
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
if (x>0) and (y<0) then
begin
write('-');
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
readln;
end.
uses crt;
var a,b,x,y:integer;
//chuongtrinhcon
function ucln(var a,b:integer):integer;
var r:integer;
begin
while b>0 do
begin
r:=a mod b;
a:=b;
b:=r;
end;
ucln:=a;
end;
//chuongtrinhchinh
begin
clrscr;
readln(a,b);
x:=a;
y:=b;
if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));
if (x<0) and (y<0) then
begin
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
if (x<0) and (y>0) then
begin
write('-');
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
if (x>0) and (y<0) then
begin
write('-');
x:=abs(x);
y:=abs(y);
a:=abs(a);
b:=abs(b);
writeln(x div ucln(a,b),' ',y div ucln(a,b));
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b;
//chuongtrinhcon
long long gcd(long long a,long long b)
{
if (b==0) return(a);
return gcd(b,a%b);
}
//chuongtrinhchinh
int main()
{
cin>>a>>b;
if ((a>0 && b>0) or (a<0 && b<0)) cout<<a/gcd(a,b)<<" "<<b/gcd(a,b);
else cout<<"-"<<-a/gcd(-a,b)<<" "<<b/gcd(-a,b);
return 0;
}
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2,sa,sd,vt1,vt2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem1:=0;
t1:=0;
dem2:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then begin inc(dem1); t1:=t1+a[i]; end;
if a[i]<0 then begin inc(dem2); t2:=t2+a[i]; end;
end;
writeln(dem1);
writeln(dem2);
writeln(t1);
writeln(t2);
for i:=1 to n do
if a[i]>0 then
begin
sd:=a[i];
vt1:=i;
break;
end;
if (dem1=0) then writeln('Khong co so duong trong day')
else writeln('So duong dau tien la: ',sd,' vi tri la: ',vt1);
for i:=1 to n do
if a[i]<0 then
begin
sa:=a[i];
vt2:=i;
break;
end;
if (dem2=0) then writeln('Khong co so am trong day')
else writeln('So am dau tien la: ',sa,' vi tri la: ',vt2);
readln;
end.
Câu 1:
var a:array[1..100]of integer;
Câu 2:
uses crt;
var a:array[1..10]of integer;
i:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 10 do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..15]of integer;
i,n,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=15);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
writeln('Mang da nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 la: ',t);
writeln('Cac so chan o vi tri le trong day la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[50],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
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.
Dạ pascal được không ạ,