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.
C1:
khai báo:
program hieu_a_va_b ("tự đặt tên cái này ko cần thiết)
uses crt;
var a, b : integer
phần thân:
begin
writeln ("nhap so a"); read(a);
writeln ("nhap so b"); read(b);
writeln ("hieu cua hai so la: a - b=" , a - b);
end.
C2:
khai báo:
program tinh_ba_so
uses crt;
var a, b, c : integer
phần thân:
begin
writeln ("nhap so a"); read(a);
writeln ("nhap so b"); read(b);
writeln ("nhap so c"); read(c);
writeln ("ket qua cua phep tinh a+b-c la" , a+b-c);
end.
C3:
khai báo:
program tinh_ba_so
uses crt;
var x, y, z : integer
phần thân:
begin
writeln ("nhap so x"); read(x);
writeln ("nhap so y"); read(y);
writeln ("nhap so z"); read(z);
writeln ("ket qua cua phep tinh (x+y)*z la") , (x+y)*z);
end.
nhớ chạy thử chương trình nha. xem có lỗi ko.
(nhớ tick cho mk nha)
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<a-b;
return 0;
}
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
Câu 1:
var i,n:integer;
s:longint;
begin
Write('n = ');readln(n)
for i:=1 to n do
s:=s+2*i+1;
write('tong la: ',s);
readln
end.
Câu 2
Bài 5:
Var b:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(b[i]);
End;
Write('Cac phan tu am la: ');
For i:=1 to n dko
if b[i]<0 then write(b[i]:8);
writeln;
max:=b[1];
For i:=2 to n do
If b[i] > max then max:=b[i];
write('So lon nhat la ',max);
Readln
End.
Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
write(a+b);
readln;
end.
Câu 2:
uses crt;
var a,b,c:integer;
begin
clrscr;
readln(a,b,c);
writeln(a+b-c);
readln;
end.
Câu 3:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln(a-b);
readln;
end.
Câu 4:
uses crt;
var x,y,z:integer;
begin
clrscr;
readln(x,y,z);
writeln((x+y)*z);
readln;
end.
Caua1:
program caumot;
begin
writeln('lop 8A chao ban!');
end.
Câu 2:
program cauhai;
int a,b,c :real;
begin
write('a='); readln(a);
write('b='); readln(b);
c= a+b;
write('Tong hai so a b la:',c);
end.
Câu 1:
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
if (a<b) cout<<a;
else cout<<b;
return 0;
}
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
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.
Câu 1:
uses crt;
var n,t,ch,dv,tr:longint;
begin
clrscr;
write('n='); readln(n);
if (100<=n) and (n<=999) then
begin
dv:=n mod 10;
ch:=n div 10; ch:=ch mod 10;
tr:=n div 100; tr:=tr mod 10;
t:=dv+ch+tr;
writeln('tong 3 chu so cua so ',n,' la: ',t);
end
else writeln('vui long nhap so co 3 chu so');
readln;
end.
Câu 2:
uses crt;
var a,b,tam:longint;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
writeln('gia tri ban dau cua a la: ',a);
writeln('gia tri ban dau cua b la: ',b);
tam:=a;
a:=b;
b:=tam;
writeln('gia tri sau khi doi cua a la: ',a);
writeln('gia tri sau khi doi cua b la: ',b);
readln;
end.
Câu 1:
var n,t,i,s:integer;
begin
write('Nhap so n: ');
readln(n);
t:=n;
for i:=1 to 3 do
begin s:=s+t mod 10;
t:=t div 10; end;
write('Tong cac chu so cua ',n,' la: ',s);
end.
Câu 2:
var a,b,t:integer;
begin
write('Nhap a: ');
readln(a);
write('Nhap b: ');
readln(b);
if a>b then begin t:=a;
a:=b;
b:=t; end;
write('a=',a,' b=',b);
end.