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.
a: 15 mod 2=1
b: 27 div 5=5
c: 17 mod 3=2
d: 21 div 2=10
e: 10 mod 4=2
f: 23 div 5=4
Bạn tham khảo code này nhé.
Uses crt;
Const fo = 'chenxau.out';
dau: array[1..3] of String[1]= ('','-','+');
s:array[1..9] of char=('1','2','3','4','5','6','7','8','9');
Var d:array[1..9] of String[1];
m:longInt;
f:text;
k:integer;
found:boolean;
Procedure Init;
Begin
Write('Cho M=');
Readln(m);
found:=false;
end;
Function tinh(s:string):longint;
Var i,t:longint;
code:integer;
Begin
i:=length(s);
While not(s[i] in ['-','+']) and (i>0) do dec(i);
val(copy(s,i+1,length(s)-i),t,code);
If i=0 then begin tinh:=t; exit; end
else
begin
delete(s,i,length(s)-i+1);
If s[i]='+' then tinh:=t+tinh(s);
If s[i]='-' then tinh:=tinh(s)-t;
end;
End;
Procedure Test(i:integer);
Var st:string; j:integer;
Begin
st:='';
For j:=1 to i do st:=st+d[j]+s[j];
If Tinh(st) = m then begin writeln(f,st); found:=true; end;
End;
Procedure Try(i:integer);
Var j:integer;
Begin
for j:=1 to 3 do
begin
d[i]:=dau[j]; Test(i);
If i<9 then try(i+1);
end;
End;
BEGIN
Clrscr;
Init;
Assign(f,fo);Rewrite(f);
for k:=1 to 2 do
begin
d[1]:=dau[k];
Try(2);
end;
If not found then write(f,'khong co ngiem');
Close(f);
END.
Program HOC24;
var i: byte;
begin
for i:=0 to 76 do write(i,' ');
readln
end.
lệnh for...to...do:
a)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 9 do s:=s+i;
write(s);
readln;
end.
b)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 14 do
begin
if i mod 2=0 then
s:=s+i;
end;
write(s);
readln;
end.
c)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 15 do
begin
if i mod 2=1 then
s:=s+i;
end;
write(s);
readln;
end.
lệnh while...do
a)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=9 do
begin
s:=s+i;
i:=i+1;
end;
write(s);
readln;
end.
b)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=14 do
begin
if i mod 2=0 then
s:=s+i
else i:=i+1;
end;
write(s);
readln;
end.
c)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=15 do
begin
if i mod 2=1 then
s:=s+i
else i:=i+1;
end;
write(s);
readln;
end.
program BaiTap;
uses crt;
var
a, b, c, i, n: integer;
D: longint;
begin
clrscr;
a:=2;
b:=3;
c:=5;
n:=7;
D:=a+b+c;
for i:=4 to n do
begin
a:=b;
b:=c;
c:=a+b;
D:=D+c;
end;
writeln('Tong la: ', D);
readln;
end.