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 dai,rong:integer;
Procedure Nhap(Var dai:integer;rong:integer);
Begin
Write('Chieu dai: ');readln(dai);
Write('Chieu rong: ');readln(rong);
End;
Procedure Ve(var dai:integer;rong:integer);
var i,j:integer;
Begin
for i:= 1 to dai do write('*');writeln;
For i:= 1 to rong-2 do
Begin
Write('*');
for j:=1 to dai-2 do write(' ');
writeln('*');
end;
for i:= 1 to dai do write('*');
End;
Begin
clrscr;
Nhap(dai,rong);
Ve(dai,rong);
readln;
End.
Tham khảo
program hcn;
uses crt;
var d,r,dt:longint;
cv:real;
begin
write('nhap chieu dai va chieu rong cua hcn:');
readln(d,r);
cv:=(d+r)*2;
dt:=d*r;
writeln(' chu vi hcn do la:',cv);
writeln(' dien tich hcn do la:',dt);
readln
end.
program UocChungLonNhat;
var
a, b: integer;
function UCLN(a, b: integer): integer;
begin
if b = 0 then
UCLN := a
else
UCLN := UCLN(b, a mod b);
end;
begin
write('Nhập số nguyên dương a: ');
readln(a);
write('Nhập số nguyên dương b: ');
readln(b);
writeln('UCLN của ', a, ' và ', b, ' là ', UCLN(a, b));
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t<<endl;
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
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;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t+=x;
}
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
min,n,i:integer;
{----------------chuong-trinh-con-------------------}
function nn(x,y:integer):integer;
begin
if x<y then nn:=x
else nn:=y;
end;
{-----------------chuong-trinh-chinh-----------------}
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=nn(a[1],a[2]);
for i:=3 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
uses crt;
var a,b:integer;
{-----------------chuong-trinh-con-tinh-chu-vi----------------------------------}
function cv(x,y:integer):integer;
begin
cv:=x+y;
end;
{-------------------chuong-trinh-con-tinh-dien-tich-----------------------------}
function dt(x,y:integer):integer;
begin
dt:=x*y;
end;
{-------------------------chuong-trinh-chinh-------------------------}
begin
clrscr;
write('Nhap chieu dai:'); readln(a);
write('Nhap chieu rong:'); readln(b);
writeln('Chu vi la: ',cv(a,b));
writeln('Dien tich la: ',dt(a,b));
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.
uses crt;
var a,b:integer;
{-----------------chuong-trinh-con-------------------}
function ucln(x,y:integer):integer;
var i,uc:integer;
begin
if x<y then
begin
uc:=1;
for i:=1 to x do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end
else begin
uc:=1;
for i:=1 to y do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end;
ucln:=uc;
end;
{--------------------------chuong-trinh-chinh------------------------}
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));
readln;
end.