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.
Program bt_3;
Uses crt;
Var Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap n=’);
Readln (n);
Tong:=0;
For i:=1 to n do
If I mod 2 = 0 then Tong:= Tong+i;
Writeln(‘Tong la:’,Tong);
Readln
End.
Program bt_3;
Uses crt;
Var Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap n=’);
Readln (n);
Tong:=0;
For i:=1 to n do
If I mod 2 = 1 then Tong:= Tong+i;
Writeln(‘Tong la:’,Tong);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,t,t1,dem,dem1;
//chuongtrinhcon
bool ktnt(long long x)
{
if (x<=1) return(false);
for (int i=2; i*i<=x; i++)
if (x%i==0) return(false);
return true;
}
//chuongtrinhchinh
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];
cout<<t<<endl;
dem=0;
for (i=1; i<=n; i++) if (a[i]%3==0) dem++;
cout<<dem<<" ";
t1=0;
dem1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
t1+=a[i];
dem1++;
}
cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;
for (i=1; i<=n; i++)
if (ktnt(a[i])==true) cout<<a[i]<<" ";
return 0;
}
Câu 1:
uses crt;
var a:array[1..500]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
if (a[i]<0) and (a[i] mod 7=0) then t:=t+a[i];
writeln('Tong cac so am chia het cho 7 la: ',t);
readln;
end.
Câu 2:
uses crt;
var c,a:array[1..10]of integer;
i,kt,j,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('C[',i,']='); readln(c[i]);
end;
dem:=0;
for i:=1 to 10 do
if c[i]>1 then
begin
kt:=0;
for j:=2 to c[i]-1 do
if c[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
a[dem]:=c[i];
end;
end;
if dem=0 then writeln('Trong day khong co so nguyen to')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem do
write(a[i]:4);
end;
readln;
end.
Câu 3:
uses crt;
var d:array[1..200]of integer;
i,k,dem:integer;
begin
clrscr;
write('Nhap k='); readln(k);
for i:=1 to k do
begin
write('D[',i,']='); readln(d[i]);
end;
dem:=0;
for i:=1 to k do
if (a[i] mod 2=0) and (a[i]>=10) then inc(dem);
writeln('So phan tu chan co 2 chu so la: ',dem);
readln;
end.
Program bt_3;
Uses crt;
Var Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap n=’);
Readln (n);
Tong:=0;
For i:=1 to n do
If I mod 3 = 0 then Tong:=Tong+i;
Writeln(‘Tong la:’,Tong);
Readln
End.
Program bt_3;
Uses crt;
Var Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap n=’);
Readln (n);
Tong:=0;
For i:=1 to n do
If I mod 5 = 0 then Tong:= Tong+i;
Writeln(‘Tong la:’,Tong);
Readln
End.
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.
Bài 1:
uses crt;
var a:array[1..200]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
if a[i] mod 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
Câu 1:
uses crt;
var n,i,t:integer;
begin
clrscr;
write('n='); readln(n);
t:=0;
for i:=1 to n do
t:=t+i;
writeln('tong cua ',n,' so nguyen dau tien la: ',t);
readln;
end.
Câu 2:
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 10 do
if i mod 2=0 then t:=t+i;
writeln('tong cac so chan trong 10 so nguyen dau tien la: ',t);
readln;
end.
Câu 3:
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 10 do
if i mod 2=0=1 then t:=t+i;
writeln('tong cac so le trong 10 so nguyen dau tien la: ',t);
readln;
end.
Câu 4:
uses crt;
var i,dem:integer;
begin
clrscr;
dem:=0;
for i:=1 to 10 do
if i mod 2=0 then inc(dem);
writeln('so cac so chan trong 10 so nguyen dau tien la: ',dem);
readln;
end.
Câu 5:
uses crt;
var i,dem:integer;
begin
clrscr;
dem:=0;
for i:=1 to 10 do
if i mod 2=1 then inc(dem);
writeln('so cac so le trong 10 so nguyen dau tien la: ',dem);
readln;
end.
Câu 6:
uses crt;
var i,n,dem:integer;
begin
clrscr;
write('n='); readln(n);
dem:=0;
for i:=1 to n do
if n mod i=0 then dem:=dem+1;
writeln('so luong uoc cua ',n,' la: ',dem);
readln;
end.
Câu 7:
uses crt;
var i,t,n:integer;
begin
clrscr;
write('n='); readln(n);
t:=0;
for i:=1 to n do
if n mod i=0 then t:=t+i;
writeln('tong cac uoc cua ',n,' la: ',t);
readln;
end.
Câu 8:
uses crt;
var n,i,dem:integer;
begin
clrscr;
write('n='); readln(n);
dem:=0;
for i:=1 to n do
if i mod 3=0 then inc(dem);
writeln('so cac so chia het cho 3 trong pham vi tu 1 toi',n,' la: ',dem);
readln;
end.
Câu 9:
uses crt;
var i,t,n:integer;
begin
clrscr;
write('n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+i;
writeln('tong cac so chia het cho 3 trong pham vi tu 1 toi ',n,' la: ',t);
readln;
end.
Nguyễn Lê Phước Thịnh cảm ơn nhiều ạ