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.
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 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.
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2,t3:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t1:=0;
t2:=0;
t3:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
if (a[i] mod 2=0) and (a[i] mod 3=0) then t3:=t3+a[i];
end;
writeln(t1);
writeln(t2);
writeln(t3);
readln;
end.
uses crt;
var a,b,c:integer;
begin
clrscr;
for a:=1 to 9 do
for b:=0 to 9 do
for c:=0 to 9 do
if (a+b+c=a*b*c) then writeln(a,b,c,' ');
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;
}
#include <bits/stdc++.h>
using namespace std;
long long i,a,b;
int main()
{
cin>>a>>b;
for (i=1; i<=min(a,b); i++)
if ((a%i==0) and (b%i==0)) cout<<i<<" ";
return 0;
}
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.