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.
#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;
}
uses crt;
var a:array[1..6]of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to 6 do
if a[i]>0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,t1,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
t1=0;
for (i=1; i<=n; i++)
{
cin>>x;
t+=x;
if (x>0)
{
dem++;
t1+=x;
}
}
cout<<"So phan tu duong la: "<<dem<<endl;
cout<<"Tong cac so duong la: "<<t1<<endl;
cout<<"Trung binh cong cua day la: "<<fixed<<setprecision(2)<<(t*1.0)/(n*1.0)<<endl;
cout<<"Trung binh cac so duong la: "<<fixed<<setprecision(2)<<(t1*1.0)/(dem*1.0);
return 0;
}
Bài 1:
uses crt;
var a:array[1..100,1..100]of integer;
m,n,i,j,k,g,tam:integer;
begin
clrscr;
write('nhap so n='); readln(n);
write('nhap so m='); readln(m);
for i:=1 to n do
for j:=1 to m do
begin
write('a[',i,',',j,']='); readln(a[i,j]);
end;
{----------------------------------------------------------}
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:4);
writeln;
end;
{----------------------------------------------------------}
writeln('day tang dan cua ma tran la: ');
for i:=1 to n do
for j:=1 to m do
for k:=1 to n do
for g:=1 to m do
if a[i,j]<a[k,g] then begin
tam:=a[k,g];
a[k,g]:=a[i,j];
a[i,j]:=tam;
end;
writeln;
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:4);
writeln;
end;
{---------------------------------------------------------}
writeln('day giam dan cua ma tran la: ');
for i:=1 to n do
for j:=1 to m do
for k:=1 to n do
for g:=1 to m do
if a[i,j]>a[k,g] then begin
tam:=a[k,g];
a[k,g]:=a[i,j];
a[i,j]:=tam;
end;
writeln;
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:4);
writeln;
end;
readln;
end.
Bài 2:
uses crt;
var a:array[1..100,1..100]of integer;
i,j,n,m,snn,sln,vtc,vth,x,z,kt,k:integer;
begin
clrscr;
{----------nhap----------}
write('nhap n: ');readln(n);
write('nhap m='); readln(m);
for i:=1 to n do
for j:=1 to m do
begin
write('a[',i,',',j,']='); readln(a[i,j]);
end;
{----------nho nhat hang----------}
for i:=1 to n do
begin
snn:=a[i,1];
for j:=1 to m do
if snn>=a[i,j] then
begin
snn:=a[i,j];
vth:=i;
vtc:=j;
end;
kt:=0;
sln:=a[vth,vtc];
for k:=1 to n do
if sln<a[k,vtc] then kt:=1;
if kt=0 then writeln(k,',',vtc);
end;
readln;
end.