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 TimSoLonNhat;
var
a, b, c, d, max: integer;
begin
write('Nhap a: '); readln(a);
write('Nhap b: '); readln(b);
write('Nhap c: '); readln(c);
write('Nhap d: '); readln(d);
max := a;
if b > max then
max := b;
if c > max then
max := c;
if d > max then
max := d;
writeln('So lon nhat la: ', max);
readln;
end.
program TimSoLonNhat;
var a, b, c, d: integer;
begin
writeln('Nhap vao gia tri cua a: ');
readln(a);
writeln('Nhap vao gia tri cua b: ');
readln(b);
writeln('Nhap vao gia tri cua c: ');
readln(c);
writeln('Nhap vao gia tri cua d: ');
readln(d);
if (a > b) and (a > c) and (a > d) then
writeln('So lon nhat la: ', a)
else if (b > a) and (b > c) and (b > d) then
writeln('So lon nhat la: ', b)
else if (c > a) and (c > b) and (c > d) then
writeln('So lon nhat la: ', c)
else
writeln('So lon nhat la: ', d);
readln;
end.
program TimSoLonNhat;
var a, b, c, d: integer;
begin
writeln('Nhap vao gia tri cua a: ');
readln(a);
writeln('Nhap vao gia tri cua b: ');
readln(b);
writeln('Nhap vao gia tri cua c: ');
readln(c);
writeln('Nhap vao gia tri cua d: ');
readln(d);
if (a > b) and (a > c) and (a > d) then
writeln('So lon nhat la: ', a)
else if (b > a) and (b > c) and (b > d) then
writeln('So lon nhat la: ', b)
else if (c > a) and (c > b) and (c > d) then
writeln('So lon nhat la: ', c)
else
writeln('So lon nhat la: ', d);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t=0;
cin>>n;
for (int i=1; i<=n; i++)
if (i%6==0) t+=i;
cout<<t;
return 0;
}
a: 125 mod 5<>0
b:
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 50 do t:=t+i;
write(t);
readln;
end.
c: for <biến đếm>:=<giá trị đầu> to <giá trị cuối> do <câu lệnh>;
d:
Dạng thiếu: if <điều kiện> do <câu lệnh>;
Dạng đủ: if <điều kiện> do <câu lệnh 1> else <câu lệnh 2>;
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t+=i;
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2!=0) t+=i;
cout<<t;
return 0;
}
2:
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<a%b<<endl;
cout<<a/b;
return 0;
}
cách 1: điều kiện dạng thiếu(chỉ có if, không có else)
uses crt;
var a,b:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if a<b then writeln('so nho nhat trong hai so la: ',a);
if b<a then writeln('so nho nhat trong hai so la: ',b);
if b=a then writeln('khong co so nho nhat trong hai so');
readln;
end,
cách 2: điều kiện dạng đủ
uses crt;
var a,b,c,kq:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if a<b then writeln('so nho nhat trong hai so la: ',a)
else if b<a then writeln('so nho nhat trong hai so la: ',b)
else writeln('khong co so nho nhat trong hai so');
readln;
end.