Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
ngomanhcuong
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

Trần Đức Huy
Xem chi tiết
Võ Quốc Bảo
14 tháng 3 2023 lúc 20:34

#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int a[32];
    int n,i,s;
    cout<<"nhap so phan tu cua mang ";
    cin>>n;
    cout<<"nhap cac phan tu cua mang ";
    for (i=1; i<=n; i++)
    {
        s=0;
        cin>>a[i];

    }
    for(i=1; i<=a[i]; i++) s=s+i;

    cout<<s;
    return 0;
}

 

 

Minh Lệ
14 tháng 3 2023 lúc 21:23

Program HOC24;

var i,n: integer;

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

t: longint;

begin

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

for i:=1 to n do

begin

write('Nhap so thu ',i,': '); readln(i);

end;

t:=0;

for i:=1 to n do t:=t+a[i];

write('Tong la: ',t);

readln

end.

Lê Gia Anh
19 tháng 3 2023 lúc 20:26

ngu thế mà cũng ko lm được dcd

Dương Mịch Lý
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 10 2021 lúc 0:51

Bài 1: 

uses crt;

var n,t,i,d,x:integer;

st:string;

begin

clrscr;

readln(n);

str(n,st);

d:=length(st);

t:=0;

for i:=1 to d do 

  begin

val(st[i],x);

t:=t+x;

end;

writeln(t);

readln;

end.

Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

Trần Cương
Xem chi tiết
Ngô Thành Chung
22 tháng 3 2022 lúc 22:07

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

      i,n,S,d:byte;

 begin

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

  for i:=1 to n do begin

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

                           readln(A[i]);

                          end;

d:=0; S:=0;

for i:=1 to n do if A[i] mod 2 = 0 then begin

                                                          d:=d+1;

                                                           S:=S+A[i];

                                                           end;

write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);

readln

end.

                                                          

                      

  

Dung
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long a,b;

//chuongtrinhcon

long long ucln(long long a,long long b)

{

if (b==0) return(a);

else return(ucln(b,a%b));

}

//chuongtrinhchinh

int main()

{

cin>>a>>b;

cout<<ucln(a,b);

return 0;

}

Họ Và Tên
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 1 2021 lúc 22:01

Câu 1: 

uses crt;

var n,i,dem,j,kt1,kt2,a,b,kt:integer;

begin

clrscr;

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

dem:=0;

if n mod 2=1 then   

begin     

a:=2;     

b:=n-a;     

kt:=0;     

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

   if b mod i=0 then kt:=1;     

if kt=0 then inc(dem);   

end

else begin       

              for i:=2 to n div 2 do         

begin             

a:=i;             

b:=n-i;             

kt1:=0;             

kt2:=0;             

for j:=2 to trunc(sqrt(a)) do               

if a mod j=0 then kt1:=1;             

for j:=2 to trunc(sqrt(b)) do               

if b mod j=0 then kt2:=1;             

if (kt1=0) and (kt2=0) then inc(dem);         

end;     

end;

writeln('So cach phan tich ',n,' thanh tong hai so nguyen to la: ',dem);

readln;

end.

Câu 2: 

uses crt;

var n,x:integer;

{-----------------ham-kiem-tra-nguyen-to-----------------}

function ktnt(x:integer):boolean;

var kt:boolean;   

i:integer;

begin   

kt:=true;   

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

if x mod i=0 then       

begin           

kt:=false;           

break;       

end;   

if kt=true then ktnt:=true   

else ktnt:=false;

end;

{---------------ham-kiem-tra-so-doi-xung---------------}

function ktdx(x:integer):boolean;

var kt:boolean;   

d,i:integer;   

st:string;

begin   

str(x,st);   

d:=length(st);   

kt:=true;   

for i:=1 to d do     

if st[i]<>st[d-i+1] then       

begin           

kt:=false;           

break;       

end;   

if kt=true then ktdx:=true   

else ktdx:=false;

end;

{--------------chuong-trinh-chinh---------------}

begin

clrscr;

repeat   

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

until n>0;

if (ktnt(n)=true) and (ktdx(n)=true) then writeln(n,' la so nguyen to doi xung')

else writeln(n,' khong la so nguyen to doi xung');

x:=n+1;

repeat   

x:=x+1;

until (ktnt(x)=true) and (ktdx(x)=true);

writeln('So nguyen to doi xung nho nhat lon hon ',n,' la: ',x);

readln;

end.

hoang
11 tháng 1 2023 lúc 22:53

bài 1;

const
fi='phantich.inp'
fo='phantich.out'
var f,g:text;i,n,d:longint;
function nt(n:longint):boolean;
var i:longint;
begin
        if (n<2) then exit (false);
        for i:=2 to trunc(sqrt(n)) do
        if (n mod i=0) then exit (false);
        exit (true);
end;
begin
        assign(f,fi);reset(f);
        assign(g,fo);rewrite(g);
        readln(f,n);
        d:=0;
        for i:=1 to n div 2 do
         if nt(i) and nt(n-i) then inc(d);
         writeln(g,'co ',d,' cach phan tich');
        close(f);close(g);
end.

bài 2:

const
fi='primenumber.inp'
fo='primenumber.out'
var f,g:text;n:longint;
function nt(n:longint):boolean;
var i:longint;
begin
        if (n<2) then exit (false);
        for i:=2 to trunc(sqrt(n)) do
        if (n mod i=0) then exit (false);
        exit (true);
end;
function check(n:longint):boolean;
var s,m:longint;
begin
        s:=0;m:=n;
        while (n>0) do
        begin
                s:=s*10+(n mod 10);
                n:=n div 10;
        end;
        if (s=m) and (nt(s)=true) then exit (true);
        exit (false);
end;
begin
        assign(f,fi);reset(f);
        assign(g,fo);rewrite(g);
        readln(f,n);
        if check(n) then writeln(g,'la so nguyen to doi xung') else
        writeln(g,'khong la so nguyen to doi xung');
        repeat
                inc(n);
        until (check(n)=true);
        writeln(g,'so do la : ',n);
        close(f);close(g);
end.

lam nguyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 12 2021 lúc 22:14

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

if (n<0) cout<<"la so am";

else cout<<"la so duong";

return 0;

}

Hàn Nhật Hạ
Xem chi tiết
Uyên  Thy
15 tháng 3 2022 lúc 23:45

Tham khảo nhen
Program Tin_hoc;

var a: integer;

begin

write('Nhap a: '); readln(a);

if a=0 then write('a la so 0') else

if a mod 2=0 then write(a,' la so chan') else write(a,' la so le');

readln

end.

kodo sinichi
16 tháng 3 2022 lúc 5:54

Tham khảo


Program Tin_hoc;

var a: integer;

begin

write('Nhap a: '); readln(a);

if a=0 then write('a la so 0') else

if a mod 2=0 then write(a,' la so chan') else write(a,' la so le');

readln

end.

Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 7:28

Câu 2:

#include <bits/stdc++.h>

using namespace std;

long long i;

int main()

{

for (i=1; i<=20; i++) cout<<i<<" ";

return 0;

}

Trần Đức Huy
Xem chi tiết
Minh Lệ
14 tháng 3 2023 lúc 21:25

Program HOC24;

var i,n: integer;

t: longint;

begin

write('Nhap so: ');

readln(n);

if n mod 2=0 then t:=n else t:=0;

while n<>0 do

begin

write('Nhap so: ');

readln(n);

if n mod 2=0 then t:=t+n;

end;

write('Ket qua la: ',t);

readln

end.