我是新手,想用Delphi编程进行计算,不知道怎样编写,比如(30x+11)(30y+19) ,x=0 to 50 ,y=0 to 50 ,if Mod[(30x+11)(30y+19),210]=89 and Mod[(30x+11)(30y+19),2310]=1139 and Mod[(30x+11)(30y+19),210]=1139 ,输出 x和y,望高手帮忙编一个,示范一下,谢谢.
var i, x, y: Intgerfor x:= 0 to 50 do begin for y:= 0 to 50 do begin i:= (30 * x + 11) * (30 * y + 19); if (i mod 210 = 89) and (i mod 2310 = 1139) and (i mod 210 = 1139) then begin // 1139 > 210 ??????????? // OUTPUT......... end; end; end;
New-->Other-->Console Applicationprogram Project1;{$APPTYPE CONSOLE}uses SysUtils; var i, x, y: Intger begin for x:= 0 to 50 do begin for y:= 0 to 50 do begin i:= (30 * x + 11) * (30 * y + 19); if (i mod 210 = 89) and (i mod 2310 = 1139) and (i mod 210 = 1139) then begin // 1139 > 210 ??????????? // OUTPUT......... end; end; end;end.
for y:= 0 to 50 do begin
i:= (30 * x + 11) * (30 * y + 19);
if (i mod 210 = 89)
and (i mod 2310 = 1139)
and (i mod 210 = 1139) then begin // 1139 > 210 ???????????
// OUTPUT.........
end;
end;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}end.
樓主可以在窗體上放兩個TEdit控件,一個用於顯示X,另一個用於顯示Y
然後再在窗體上加上一個TButton,然後雙擊之
在那個裡面寫上你的算法代碼,即可
SysUtils;
var
i, x, y: Intger
begin
for x:= 0 to 50 do begin
for y:= 0 to 50 do begin
i:= (30 * x + 11) * (30 * y + 19);
if (i mod 210 = 89)
and (i mod 2310 = 1139)
and (i mod 210 = 1139) then begin // 1139 > 210 ???????????
// OUTPUT.........
end;
end;
end;end.