Những câu hỏi liên quan
Tinh Hy
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 12 2021 lúc 22:58

Câu 3: 

#include <bits/stdc++.h>

using namespace std;

string a[1000];

int n,i,dem;

int main()

{

cin>>n;

dem=0;

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

{

cin>>a[i];

if (a[i]=='a') dem++;

}

cout<<dem;

return 0;

}

Nguyễn Mỹ
Xem chi tiết
nguyễn an phát
5 tháng 4 2021 lúc 18:23

Bài 1:

program in_phan_tu;

uses crt;

var n,i:longint;

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

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]:3);

readln;

end.

Bài 2:

program tong_phan_tu;

uses crt;

var n,i,tong:longint;

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

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;

tong:=0;

for i:=1 to n do

tong:=tong+a[i];

writeln('tong cua day la:');

readln;

end.

Bài 3:

program tong_phan_tu_chan;

uses crt;

var n,i,tong:longint;

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

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;

tong:=0;

for i:=1 to n do

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

writeln('tong cua day la:');

readln;

end.

Nguyễn Lê Phước Thịnh
5 tháng 4 2021 lúc 19:50

Câu 1: 

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do 

  write(a[i]:4);

readln;

end.

Nguyễn Lê Phước Thịnh
5 tháng 4 2021 lúc 19:51

Câu 2: 

uses crt;

var a:array[1..100]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 

 t:=t+a[i];

writeln(t);

readln;

end.

Linh Nga Nguyễn
Xem chi tiết
Sơn Mai Thanh Hoàng
15 tháng 3 2022 lúc 15:05

1 không

2 

 Program UCLN;

uses crt;

var a,b : integer;

begin

write ('nhap so a la ');readln (a);

write ('nhap so b la ');readln (b);

while a < > b do

if a >b then a := a - b else b := b - a ;

write ( ' UCLN la :' , a );

readln

end.

Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:33

1: 

#include <bits/stdc++.h>

using namespace std;

int n,i;

bool kt;

int main()

{

cin>>n;

kt=true;

for (i=2; i*i<=n; i++)

if (n%i==0) kt=false;

if (kt==true && n>1) cout<<"La so nguyen to";

else cout<<"Khong la so nguyen to";

return 0;

}

Cún đi hỏi bài
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 5 2021 lúc 20:36

uses crt;

var a,b:integer;

{-------------------thu-tuc-nhap-------------------}

procedure nhap(var n:integer);

begin

write('Nhap so tu nhien:'); readn(n);

end;

{---------------------ham-tinh-tong----------------------}

function tong(x,y:integer):integer;

begin

tong:=x+y;

end;

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

begin

clrscr;

nhap(a);

nhap(b);

writeln(tong(a,b));

readln;

end.

M Ạ C H N H A
Xem chi tiết
Trần Thị Thèo Lèo
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 3 2022 lúc 23:13

#include <bits/stdc++.h>

using namespace std;

long long b[5],i,n,k,dem,kt;

int main()

{

n=5;

for (i=1; i<=n; i++) cin>>b[i];

for (i=1; i<=n; i++) cout<<b[i]<<" ";

cout<<endl;

dem=0;

for (i=1; i<=n; i++) if (b[i]%2==0) dem++;

cout<<"So so chan la: "<<dem<<endl;

cin>>k;

kt=0;

for (i=1; i<=n; i++) if (b[i]==k) 

{

cout<<i<<" ";

kt=1;

}

if (kt==0) cout<<"Khong co k trong day";

sort(b+1,b+n+1);

for (i=1; i<=n; i++) cout<<b[i]<<" ";

return 0;

}

Trần Thị Thèo Lèo
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2022 lúc 12:51

uses crt;

var b:array[1..5]of integer;

i,n,dem,k,tam,j:integer;

kt:boolean;

begin

clrscr;

n:=5;

for i:=1 to n do readln(b[i]);

for i:=1 to n do write(b[i]:4);

writeln;

dem:=0;

for i:=1 to n do if b[i] mod 2=0 then dem:=dem+1;

writeln('So luong so chan la: ',dem);

readln(k);

kt:=false;

for i:=1 to n do 

if b[i]=k then

begin

write(i:4);

kt:=true;

end;

if (kt==false) then writeln('Khong co k trong day')

else writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if b[i]>b[j] then 

begin

tam:=b[i];

b[i]:=b[j];

b[j]:=tam;

end;

for i:=1 to n do write(b[i]:4);

readln;

end.

Không tên
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2022 lúc 22:42

#include <bits/stdc++.h>

using namespace std;

long long b[15],i,n,k,dem;

bool kt;

int main()

{

n=15;

for (i=1; i<=n; i++) cin>>b[i];

for (i=1; i<=n; i++) cout<<b[i]<<" ";

cout<<endl;

dem=0;

for (i=1; i<=n; i++) if (b[i]%2==0) dem++;

cout<<"So so chan la: "<<dem<<endl;

cin>>k;

kt=false;

for (i=1; i<=n; i++) if (b[i]==k) 

{

cout<<i<<" ";

kt=true;

}

if (kt==false) cout<<"Khong co k trong day";

else cout<<endl;

sort(b+1,b+n+1);

for (i=1; i<=n; i++) cout<<b[i]<<" ";

return 0;

}

Bùi Ngọc Phụng
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 12 2021 lúc 23:06

#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;

t=t+x;

}

cout<<sqrt(t);

return 0;

}