Những câu hỏi liên quan
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 1 2021 lúc 8:53

uses crt;

var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;   

a,b:array[1..100]of integer;   

st:string;

begin

clrscr;

write('Nhap n='); readln(n);

str(n,st);

d:=length(st);

for i:=1 to d do 

val(st[i],a[i],x);

dem:=1;

b[1]:=a[1];

for i:=1 to d do 

begin     

kt:=0;     

for j:=1 to dem do       

if a[i]=b[j] then kt:=1;     

if kt=0 then       

begin           

inc(dem);           

b[dem]:=a[i];       

end; 

end;

writeln('Cac chu so cua ',n,' la: ');

for i:=1 to dem do 

write(b[i]:4);

writeln;

t:=0;

for i:=1 to d do 

t:=t+a[i];

writeln('Tong cac chu so cua ',n,' la: ',t);

kt1:=0;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt1:=1;       

break;     

end;

if (kt1=0) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac chu so o vi tri le cua ',n,' la: ');

t1:=0;

for i:=1 to d do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac chu so o vi tri le la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac chu so o vi tri chan cua ',n,' la: ');

t2:=0;

for i:=1 to d do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln('Tong cac chu so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to d 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);

writeln('Tong cua chung la: ',max+min);

readln;

end.

Bình luận (0)
Ngáo Ngơ Alice
Xem chi tiết
nguyễn an phát
11 tháng 4 2021 lúc 12:02

program timtich;

uses  crt;

var i,n:integer;

tich:longint;

a:array[1..100]of integer;

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

write('nhap phan tu a[',i,']:');readln(a[i]);

end;

for i:=1 to n do

write(a[i]:4);

tich:=1;

writeln;

for i:=1 to n do

if a[i] mod 2=0 then tich:=tich*a[i];

writeln('tich ca phan tu chan cua mang la:',tich);

readln;

end.

program timtong;

uses  crt;

var i,n:integer;

tong:longint;

a:array[1..100]of integer;

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

write('nhap phan tu a[',i,']:');readln(a[i]);

end;

for i:=1 to n do

write(a[i]:4);

tong:=0;

writeln;

for i:=1 to n do

if a[i] mod 2=0 then tong:=tong+a[i];

writeln('tong cac phan tu chan cua mang la:',tong);

tong:=0;

writeln;

for i:=1 to n do

if a[i] mod 2=1 then tong:=tong+a[i];

writeln('tong cac phan tu le cua mang la:',tong);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:56

Bài 1: 

uses crt;

var a:array[1..100]of integer;

i,n,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

s:=1;

for i:=1 to n do 

  if a[i] mod 2=0 then s:=s*a[i];

writeln(s);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:57

uses crt;

var a:array[1..100]of integer;

i,n,t1,t2:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

t1:=0;

t2:=0;

for i:=1 to n do

begin

if a[i] mod 2=0 then t1:=t1+a[i]

else t2:=t2+a[i];

end;

writeln('Tong cac so chan la: ',t1);

writeln('Tong cac so le la: ',t2);

readln;

end.

Bình luận (0)
trần hoàng
Xem chi tiết
Lê Trần Kim Hoàng
7 tháng 2 2023 lúc 10:09

program ct;
uses crt;
var dem,n,s,max,t:longint;
begin
        writeln('nhap n:');readln(n);
        while n>0 do begin
                        s:=n mod 10;
                        t:=t+s;
                        if max<s then max:=s;
                        dem:=dem+1;
                        n:=n div 10;
                     end;
        writeln('tong la',t,',','co',' ',dem,' ','chu so',',','chu so lon nhat la:',max);
        readln
end.

bạn xem lại nha mik làm đây nhưng k bt đk

Bình luận (0)
05. Huỳnh Thị Thùy Dung
Xem chi tiết
Trương Huy Hoàng
12 tháng 10 2021 lúc 22:13

Mình dùng C++ nên div = /; mod = % nha bn!

#include <bits/stdc++.h>
using namespace std;
int main() {
int a, S;
cin >> a;
S=0;
while(a>0)
{
    S+=a%10, a=a/10;
}
cout << S << endl;
return 0;
}

Chúc bn học tốt!

Bình luận (1)
Trần Long
Xem chi tiết
Xyz OLM
7 tháng 2 2023 lúc 12:03

 

Bình luận (0)
Nguyễn Gia Viễn
Xem chi tiết
le manh vu
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 2 2022 lúc 22:51

Bài 1: 

#include <bits/stdc++.h>

using namespace std;

long long a[10],i;

bool kt;

int main()

{

for (i=1; i<=10; i++) cin>>a[i];

kt=true;

for (i=1; i<=9; i++) if (a[i]>a[i+1]) kt=false;

if (kt==true) cout<<"YES";

else cout<<"NO";

return 0;

}

Bình luận (0)
My Nguyen
Xem chi tiết
Lý Tâm Như
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 12 2020 lúc 21:36

uses crt;

var n,dv,ch:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (10<=n) and (n<=99);

dv:=n mod 10;

ch:=n div 10;

writeln('Tong cac chu so la: ',dv+ch);

readln;

end.

Bình luận (0)