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 n,i:integer;
s:real;
begin
clrscr;
write('n='); readln(n);
if (n>=0) and (n<=100) then
begin
s:=0;
for i:=1 to n do
s:=s+(i/(i+1));
writeln('tong la: ',s);
end
else writeln('vui long nhap lai');
readln;
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cout<<"Day ban dau la: "<<endl;
for (i=1;i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
sort(a+1,a+n+1);
cout<<"Day tang dan la: "<<endl;
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
Var n,sc,sl,i:longint;
Begin
Write('N = ');readln(n);
Write('Cac so tu 1 den ',n,' la ');
For i:=1 to n do
Write(i:8);
Writeln;
For i:=1 to n do
Begin
If i mod 2 = 0 then sc:=sc+i
Else sl:=sl+i;
End;
Writeln('Tong cac so chan la ',sc);
Write('Tong cac so le la ',sl);
Readln
End.
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
write('nhap n='); readln(n);
if n=1 then a[1]:=2
else begin
a[1]:=2;
x:=1;
dem:=1;
repeat
x:=x+2;
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=1;
if kt=0 then begin
inc(dem);
a[dem]:=x;
end;
until dem=n;
end;
{-----------------------------------------}
writeln(n,' so nguyen to dau tien la:');
for i:=1 to n do
write(a[i]:4);
{--------------------------}
readln;
end.
uses crt;
var n,dem,dem1,i,t:integer;
tbc:real;
begin
clrscr;
write('n='); readln(n);
if (0<n) and (n<1000) then
begin
{----------------------dong-1----------------------}
dem:=0;
for i:=1 to n do
if i mod 2=1 then inc(dem);
writeln('so luong cac so nguyen le tu 1 toi ',n,' la: ',dem);
{---------------------dong-2-----------------------}
dem1:=0;
for i:=1 to n do
if i mod 2=0 then inc(dem1);
writeln('so luong cac so nguyen chan tu 1 toi ',n,' la: ',dem1);
{--------------------dong-3------------------------}
t:=0;
for i:=1 to n do
t:=t+i;
tbc:=t/n;
writeln('trung binh cong cac so nguyen tu 1 toi ',n,' la: ',tbc:4:2);
end
else writeln('vui long nhap lai');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b,bcnn;
int main()
{
cin>>a>>b;
if (a>b) swap(a,b);
bcnn=b;
while (bcnn%a!=0)
bcnn=bcnn+b;
cout<<bcnn;
return 0;
}
uses crt;
var n,t:int64;
dem,i:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
until (0<n) and (n<1000000000);
writeln('Cac so chinh phuong trong khoang tu 1 toi ',n,' la: ');
dem:=0;
t:=0;
for i:=1 to n do
if sqrt(i)=trunc(sqrt(i)) then
begin
write(i:6);
inc(dem);
t:=t+i;
end;
writeln;
writeln('So so chinh phuong trong khoang tu 1 toi ',n,' la: ',dem);
writeln('Tong cac so chinh phuong trong khoang tu 1 toi ',n,' la: ',t);
readln;
end.
Câu 1:
Program hotrotinhoc;
var i,n: longint;
x,tl,tc,min,max,k: integer;
begin
write('Nhap so chu so : '); readln(k);
write('Nhap so nguyen N : '); readln(n);
max:=0; min:=99999; tl:=0; tc:=0;
while n<>0 do
begin
x:=n mod 10;
if max<x then max:=x;
if min>x then min:=x;
if x mod 2<>0 then tl:=tl+x;
if x mod 2=0 then tc:=tc+x;
x:=x div 10;
end;
writeln('Chu so lon nhat la : ',max,' ; ',' Chu so be nhat la : ',min);
writeln('Tong cac chu so la chu so le la :',tl);
write('Tong cac chu so la chu so chan la :',tc);
readln
end.
Bài 1: Sửa đề: Dòng 3: Tổng các chữ số là chữ số chẵn trong N
uses crt;
var n,k,i,x,max,min,t,t1:integer;
a:array[1..4]of integer;
st:string;
begin
clrscr;
write('n='); readln(n);
if n>0 then
begin
str(n,st);
k:=length(st);
if (2<k) and (k<5) then
begin
{------------------------dong-1------------------------}
for i:=1 to k do
val(st[i],a[i],x);
max:=a[1];
min:=a[1];
for i:=1 to k do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('chu so lon nhat cua ',n,' la: ',max);
writeln('chu so nho nhat cua ',n,' la: ',min);
{----------------------dong-2------------------------}
t:=0;
for i:=1 to k do
if a[i] mod 2<>0 then t:=t+a[i];
writeln('tong cac chu so la chu so le trong ',n,' la: ',t);
{---------------------dong-3-------------------------}
t1:=0;
for i:=1 to k do
if a[i] mod 2=0 then t1:=t1+a[i];
writeln('tong cac chu so la chu so chan trong ',n,' la: ',t1);
end
else writeln('vui long nhap lai');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var n,i,t,d,y,kt,kt1:integer;
a:array[1..3]of integer;
st:string[3];
begin
clrscr;
write('n='); readln(n);
if (100<=n) and (n<=999) then
begin
str(n,st);
d:=length(st);
{--------------------------dong-1-------------------}
t:=0;
for i:=1 to d do
begin
val(st[i],a[i],y);
t:=t+a[i];
end;
writeln('tong cac chu so cua so ',n,' la: ',t);
{-------------------------dong-2---------------------}
kt:=0;
for i:=1 to d do
if a[i] mod 2=0 then
begin
kt:=1;
write(a[i]:4);
end;
if kt=0 then writeln('KHONG CO');
{-----------------------dong-3----------------------}
writeln;
kt1:=0;
for i:=1 to d do
if a[i] mod 2=1 then
begin
kt1:=1;
write(a[i]:4);
end;
if kt1=0 then writeln('KHONG CO');
end
else writeln('vui long nhap lai');
readln;
end.
uses crt;
var n,i:longint;
t:real;
begin
clrscr;
write('n='); readln(n);
if (1<=n) and (n<=10000) then
begin
t:=0;
for i:=1 to n do
t:=t+(1/(sqr(i)));
writeln('T=',t:4:2);
end
else writeln('vui long nhap lai n');
readln;
end.