掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
教えてください (ID:16677)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Delphiで簡単に書くとこんなもんですかね・・・ var i: array [1..24] of integer; s: String; sData: String; iMax, iMin: integer; begin if (StrToInt(Edit1.Text) mod 1111) = 0 then begin ShowMessage('1111で割り切れます!!'); Exit; end; sData := Edit1.Text; while True do begin s := Format('%.4d', [StrToInt(sData)]); //0000〜9999 i[1] := StrToInt(s[1] + s[2] + s[3] + s[4]); i[2] := StrToInt(s[1] + s[2] + s[4] + s[3]); i[3] := StrToInt(s[1] + s[3] + s[2] + s[4]); i[4] := StrToInt(s[1] + s[3] + s[4] + s[2]); i[5] := StrToInt(s[1] + s[4] + s[2] + s[3]); i[6] := StrToInt(s[1] + s[4] + s[3] + s[2]); i[7] := StrToInt(s[2] + s[1] + s[3] + s[4]); i[8] := StrToInt(s[2] + s[1] + s[4] + s[3]); i[9] := StrToInt(s[2] + s[3] + s[1] + s[4]); i[10] := StrToInt(s[2] + s[3] + s[4] + s[1]); i[11] := StrToInt(s[2] + s[4] + s[1] + s[3]); i[12] := StrToInt(s[2] + s[4] + s[3] + s[1]); i[13] := StrToInt(s[3] + s[1] + s[2] + s[4]); i[14] := StrToInt(s[3] + s[1] + s[4] + s[2]); i[15] := StrToInt(s[3] + s[2] + s[1] + s[4]); i[16] := StrToInt(s[3] + s[2] + s[4] + s[1]); i[17] := StrToInt(s[3] + s[4] + s[1] + s[2]); i[18] := StrToInt(s[3] + s[4] + s[2] + s[1]); i[19] := StrToInt(s[4] + s[1] + s[2] + s[3]); i[20] := StrToInt(s[4] + s[1] + s[3] + s[2]); i[21] := StrToInt(s[4] + s[2] + s[1] + s[3]); i[22] := StrToInt(s[4] + s[2] + s[3] + s[1]); i[23] := StrToInt(s[4] + s[3] + s[1] + s[2]); i[24] := StrToInt(s[4] + s[3] + s[2] + s[1]); iMax := MaxIntValue(i); iMin := MinIntValue(i); sData := IntToStr(iMax - iMin); ListBox1.Items.Add(IntToStr(iMax) + ' - ' + IntToStr(iMin) + ' = ' + sData); //確認 if sData = '6174' then begin ShowMessage(IntToStr(iMax) + ' - ' + IntToStr(iMin) + ' = 6174'); Break; end; end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.