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:
const fi='so.inp';
fo='so.out';
var f1,f2:text;
a:array[1..100]of integer;
dem,i,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,a[dem]);
end;
writeln(f2,'Cac so nguyen am la: ');
for i:=1 to dem do
if a[i]<0 then write(f2,a[i]:4);
writeln(f2);
t:=0;
for i:=1 to dem do
if (a[i] mod 5=0) and (a[i] mod 3=0) then t:=t+a[i];
writeln(f2,'Tong cac so chia het cho 3 va 5 la: ',t);
close(f1);
close(f2);
end.
Bài 2:
uses crt;
const fi='baitap.txt';
fo='kq.qut';
var f1,f2:text;
a:array[1..100]of integer;
dem,i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eoln(f1) do
begin
inc(n);
read(f1,a[n]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 5=0 then dem:=dem+1;
writeln('So luong cac so chia het cho 5 la: ',dem);
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then write(f2,a[i]:4);
close(f1);
close(f2);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
uses crt;
const fi='baitap.txt';
var f1:text;
a,b,c,d:array[1..100]of real;
i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n],b[n],c[n],d[n]);
end;
for i:=1 to n do
writeln(sqrt(sqr(a[i]-c[i])+sqr(b[i]-d[i])):4:3);
close(f1);
readln;
end.
Program HOC24;
var m,n,i: integer;
t1,t2: longint;
begin
write('Nhap m;n: '); readln(m,n);
t1:=1; t2:=1;
for i:=1 to n do t1:=t1*i;
for i:=m to n do t2:=t2*i;
writeln('T1=',t1);
write('T2=',t2);
readln
end.
1:
uses crt;
const fi='songuyen.doc';
var i:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
for i:=1 to 10 do write(f1,i:4);
close(f1);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,min,dem1,dem2,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
dem1:=0;
dem2:=0;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
inc(dem1);
t1:=t1+a[i];
end
else begin
inc(dem2);
t2:=t2+a[i];
end;
end;
writeln('So so chan la: ',dem1);
writeln('So so le la: ',dem2);
writeln('Tong cac so chan la: ',t1);
writeln('Tong cac so le la: ',t2);
readln;
end.
Câu 1:
const fi='dulieu.inp';
fo='ketqua.out';
var f1,f2:text;
m,n,t,i:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,m,n);
t:=0;
for i:=m to n do
if i mod 2=1 then t:=t+i;
writeln(f2,t);
close(f1);
close(f2);
end.
uses crt;
const fi='songuyen.inp';
fo='songuyen2.out';
var a:array[1..100]of integer;
i,n,t1:integer;
f1,f2:text;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
t1:=0;
for i:=1 to n do if a[i] mod 2<>0 then t1:=t1+a[i];
writeln(t1);
writeln(f2,t1);
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
close(f1);
close(f2);
readln;
end.
uses crt;
var a,b:integer;
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
until (a>0) and (b>0);
if a>b then writeln(a,' la so lon hon')
else if a<b then writeln(b,' la so lon hon')
else writeln('Hai so bang nhau');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b;
//chuongtrinhcon
long long gcd(long long a,long long b)
{
if (b==0) return(a);
return gcd(b,a%b);
}
//chuongtrinhchinh
int main()
{
freopen("songuyen.inp","r",stdin);
cin>>a>>b;
cout<<gcd(a,b);
return 0;
}
uses crt;
const fi='baitap.txt';
var f1:text;
x,y:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,x,y);
writeln(sqrt(x*x+y*y):4:2);
close(f1);
readln;
end.