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 dem,n,m,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Nhap m='); readln(m);
t:=m+n;
writeln('Trung binh cong cua chung la: ',t/2:4:2);
dem:=0;
if n mod m=0 then inc(dem);
if m mod n=0 then inc(dem);
writeln('Co ',dem,' so la boi so cua so kia');
readln;
end.
#include <iostream>
using namespace std;
int main()
{
int a[100][100],i,j,m,n;
cout<<"Nhap so dong cua mang:"; cin>>n;
cout<<"Nhap so cot cua mang:"; cin>>m;
for (i=1; i<=n; i++)
for (j=1; j<=m; j++)
{
cout<<"A["<<i<<","<<j<<"]="; cin>>a[i][j];
}
for (i=1; i<=n; i++)
{
for (j=1; j<=m; j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}
uses crt;
var a:array[1..10]of integer;
i,t:integer;
begin
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to 10 do
t:=t+a[i];
writeln('Tong cua day la: ',t);
writeln('Trung binh cong cua day la: ',t/n:4:2);
readln;
end.
2:
#include <bits/stdc++.h>
using namespace std;
double a,b,c,p,s;
int main()
{
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
double b[100],x,ln,t;
int i,n,dem;
int main()
{
cin>>n;
ln=-1e10;
for (i=1; i<=n; i++)
{
cin>>b[i];
ln=max(ln,b[i]);
}
for (i=1; i<=n; i++)
cout<<b[i]<<" ";
cout<<endl;
cout<<ln<<endl;
t=0;
dem=0;
for (i=1; i<=n; i++)
if (a[i]>x)
{
t=t+a[i];
dem++;
}
cout<<fixed<<setprecision(2)<<t/(dem*1.0);
return 0;
}
Tham khảo
uses crt;
var n,i,ta,td,d1,d2:integer;
a:array[1..100]of integer;
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
td:=0;
d1:=0;
for i:=1 to n do
if a[i]>0 then
begin
td:=td+a[i];
inc(d1);
end;
writeln('Trung binh cong cac so duong la: ',td/d1:4:2);
d2:=0;
ta:=0;
for i:=1 to n do
if a[i]<0 then
begin
inc(d2);
ta:=ta+a[i];
end;
writeln('Trung binh cong cac so am la: ',ta/d2:4:2);
readln;
end.
Bài 1:
Program HOC24;
var i,n,d : byte;
t: integer;
begin
write('Nhap 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 if (a[i] mod 3=0) and (a[i] mod 5=0) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' phan tu la boi cua 3 va 5');
write('Tong la: ',t);
readln
end.
Bài 2:
Program HOC24;
var i,n,k : byte;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
write('Nhap k: '); readln(k);
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Co ',d,' phan tu bang ',k);
Write('Cac chi so do la: ');
for i:=1 to n do if a[i]=k then write(i,' ');
readln
end.
uses crt;
var dem,n,m,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Nhap m='); readln(m);
t:=m+n;
writeln('Trung binh cong cua chung la: ',t/2:4:2);
dem:=0;
if n mod m=0 then inc(dem);
if m mod n=0 then inc(dem);
writeln('Co ',dem,' so la boi so cua so kia');
readln;
end.