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.
1:
uses crt;
var a,b:real;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
if a<>0 then writeln('Nghiem cua phuong trinh la: ',-b/a:4:2)
else writeln('Phuong trinh vo nghiem');
readln;
end.
2:
uses crt;
var n:real;
begin
clrscr;
write('Nhap n='); readln(n);
if n>=0 then writeln('Can bac hai cua n la: ',trunc(sqrt(n)))
else writeln(n,' khong co can bac hai');
readln;
end.
3:
uses crt;
var a,b,c:real;
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
until (a>0) and (b>0) and (c>0);
if (a+b>c) and (a+c>b) and (b+c>a) then writeln('Day la do dai ba canh trong mot tam giac')
else writeln('Day khong la do dai ba canh trong mot tam giac');
readln;
end.
Bài 2:
uses crt;
var x,i,n,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then inc(dem);
end;
writeln(dem);
readln;
end.
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;
writeln('Mang nguoc la: ');
for i:=n downto 1 do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then t:=t+a[i];
writeln('Tong cac so chan co chi so le la: ',t);
writeln('Cac so chia het cho 2 va 5 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i] mod 5=0) then write(a[i]:4);
readln;
end.
uses crt;
var a,b,c,d,tl,tc:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
write('Nhap d='); readln(d);
tc:=0;
tl:=0;
if a mod 2=0 then tc:=tc+a
else tl:=tl+a;
if b mod 2=0 then tc:=tc+b
else tl:=tl+b;
if c mod 2=0 then tc:=tc+c
else tl:=tl+c;
if d mod 2=0 then tc:=tc+d
else tl:=tl+d;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
readln;
end.
Câu 1:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
int t=0;
while (n>0)
{
int x=n%10;
t=t+x;
n=n/10;
}
cout<<t;
return 0;
}
1:
uses crt;
var a,b:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
if (a>0) and (b>0) then writeln('Cung dau');
if (a<0) and (b<0) then writeln('Cung dau');
if (a>0) and (b<0) then writeln('Khac dau');
if (a<0) and (b>0) then writeln('Khac dau');
readln;
end.
2:
uses crt;
var n,i,d,t,x,y:integer;
st:string;
begin
clrscr;;
repeat
write('Nhap n='); readln(n);
until (100<=n) and (n<=999);
str(n,st);
d:=length(st);
t:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if x mod 2=1 then t:=t+x;
end;
writeln('Tong cac chu so le cua ',n,' la: ',t);
readln;
end.