Nhập N số bất kì .
Đếm các số lớn hơn 10 và nhỏ hơn 20 và tính tổng của chúng . Sau đó , đưa ra màn hình :So cac so >10 và <20 la : ( gia tri ) ;Tong cua chung la : ( gia tri )
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.
Câu 4:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if (10<a[i]) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu lon hon 10 va nho hon 20 la: ',dem);
writeln('Tong cac phan tu lon hon 10 va nho hon 20 la: ',t);
readln;
end.
Câu 5:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So so chan la: ',dem);
writeln('Tong cac so chan la: ',t);
readln;
end.
#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;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if (10<a[i]) and (a[i]<20) then inc(dem);
writeln(dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('Trong day co ',dem,' so chan');
readln;
end.
uses crt;
var n,i,dem:byte;
a:array[1..100] of longint;
tong:longint;
begin
clrscr;
write('nhap N:');readln(n);
writeln('nhap N so:');
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
dem:=0; tong:=0;
for i:=1 to n do
begin
if (a[i]>10) and (a[i]<20) then
begin
dem:=dem+1;
tong:=tong+a[i];
end;
end;
if dem=0 then write('khong co so lon hon 10 va nho hon 20');
readln;
end.
chuc ban hoc tot
1:
uses crt;
var t,x,i,n:integer;
begin
clrscr;
t:=0;
n:=10;
for i:=1 to n do
begin
readln(x);
t:=t+x;
end;
write(t);
readln;
end.
2:
uses crt;
var dem,x,i,n:integer;
begin
clrscr;
dem:=0;
n:=10;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then inc(dem);
end;
write(dem);
readln;
end.
3
program Cacsole;
uses crt;
var M, N, i: integer;
begin
clrscr;
write ('Nhap M= '); readln(M);
write ('Nhap N= '); readln(N);
for i := M to N do
if i mod 2 = 1 then
write (i,' ');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
1:
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
2:
uses crt;
var n,dem,i,t:integer;
a:array[1..100]of integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly----------------------------}
dem:=0;
t:=0;
for i:=1 to n do
if (a[i]>10) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('so cac so lon hon 10 va nho hon 20 la: ',dem);
writeln('tong cua chung la: ',t);
readln;
end.
1:
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
2:
uses crt;
var n,dem,i,t:integer;
a:array[1..100]of integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly----------------------------}
dem:=0;
t:=0;
for i:=1 to n do
if (a[i]>10) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('so cac so lon hon 10 va nho hon 20 la: ',dem);
writeln('tong cua chung la: ',t);
readln;
end.
Var Tong , So : Real ; I , N , Dem : Integer ;
BEGIN
Write (` Bao nhieu so : `) ; Readln ( N ) ;
Tong := 0 ; Dem := 0 ;
For I := 1 To N Do
Begin
Write (` So = `) ; Readln ( So ) ;
If ( So > 10 ) and ( So < 20 ) Then
Begin
Tong := Tong + So ;
Dem := Dem + 1 ;
End ;
End ;
Writeln (` So cac so >10 va <20 la : `, Dem ) ;
Writeln (` Tong cua chung la :`, Tong ) ;
Readln ;
END .