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: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.
Câu 1:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
int t=0;
while (n>0)
{
int x=n%10;
t=t+x;
n=n/10;
}
cout<<t;
return 0;
}
uses crt;
const fi='kiemtra.txt';
var f1:text;
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.
Mình xin sửa lại một chút:
uses crt;
const fi='kiemtra.txt';
var f1:text;
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;
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
min:=nn(a[1],a[2]);
for i:=3 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
2:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
if (n%i==0) cout<<i<<" ";
return 0;
}
Bài 2:
#include <bits/stdc++.h>;
using namespace std;
int main();
{
long m,n;
cout<<"Nhap m="; cin>>m;
cout<<"Nhap n="; cin>>n;
cout<<m*n-2;
return 0;
}
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
begin
if st[i]=' ' then writeln
else write(st[i]);
end;
readln;
end.
#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;
}
Bài 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,t,dem;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
if (i%2==1)
{
t=t+i;
dem++;
}
cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0);
return 0;
}