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.
Bài 1:program sothuc;
uses crt;
var a:array[1..10] of real;s,i,j:real;
begin
s:=0;
for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;
for i:=1 to 10 do if a[i]<0 then
for j:=1 to 10 do
begin a[j]:=sqr(a[i]); s:=s+a[j]; end;
writeln('tong binh phuong cac so am la: ',s:2:2); readln;
end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)
Bài 2:
program soduong;
uses crt;
var a:array[1..100] of integer;s,i,n:integer;
begin
clrscr;
writeln('nhap do dai cua day');readln(n);
for i:=1 to n do begin
writeln('a[',i,']=');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i] end;
writeln('tong so duong trong day la',s:2:0);readln
end.
Bài 3: các số dương mà là số lẻ là sao thế bạn????
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.
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.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
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.
Câu 1:
Program HOC24;
var i,p: integer;
t: longint;
begin
write('Nhap P: '); readln(p);
t:=0;
for i:=1 to p do if i mod 2<>0 then t:=t+i;
write('Tong cac so le la: ',t);
readln
end.
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.
Bài 1:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
if i mod 6=0 then s:=s+i;
writeln(s);
readln;
end.
Bài 2:
uses crt;
var a,b,c,ucln,i:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
while a<>b do
begin
if a>b then a:=a-b
else b:=b-a;
end;
ucln:=a;
while ucln<>c do
begin
if ucln>c then ucln:=ucln-c
else c:=c-ucln;
end;
writeln(ucln);
readln;
end.
Bài 1:
Program hotrotinhoc;
var i,n: integer;
t: longint;
begin
write('Nhap n='); readln(n);
for i:=1 to n do
if (i mod 3=0) or (i mod 5=0) then t:=t+i;
write(t);
readln
end.
Bài 2: Bạn tham khảo bài 2 ở link sau Câu hỏi của dang thi khanh ly - Tin học lớp 11 | Học trực tuyến
Bài 3:
program hotrotinhoc;
var d,i,n: integer;
a: array[1..32000] of integer;
t: longint;
begin
write('Nhap n='); readln(n);
d:=0; t:=0;
for i:=1 to n do
begin
write('Nhap so thu ',i,':'); readln(a[i]);
if (a[i]>10) and (a[i]<20) then
begin
inc(d);
t:=t+a[i];
end;
end;
Writeln('Cac so lon hon 10 va nho hon 20 la ',d);
write('Tong cua chung la :',t);
readln
end.
Bài 1:
uses crt;
var n,i,t:longint;
begin
clrscr;
write('n='); readln(n);
if n>0 then
begin
t:=0;
for i:=1 to n do
if (i mod 3=0) or (i mod 5=0) then t:=t+i;
writeln('tong cac so la boi cua 3 hoac 5 la: ',t);
end
else writeln('vui long nhap so nguyen duong');
readln;
end.
Bài 2:
uses crt;
var a,b,c:real;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
if (a>0) and (b>0) and (c>0) then
begin
if (a+b>c) and (a+c>b) and (b+c>a) then writeln('day la do dai 3 canh trong mot tam giac')
else writeln('day khong la do dai 3 canh trong mot tam giac');
end
else writeln('vui long nhap ba so duong');
readln;
end.
Bài 3:
uses crt;
var n,i,t,dem:longint;
a:array[1..100]of longint;
begin
clrscr;
write('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]>10) and (a[i]<20) then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('cac so lon hon 10 va nho hon 20 la: ',dem);
writeln('tong cua chung la: ',t);
readln;
end.