[過去ログ]
スレ立てるまでもない質問はここで 152匹目 (1002レス)
スレ立てるまでもない質問はここで 152匹目 http://mevius.5ch.net/test/read.cgi/tech/1573214616/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
605: デフォルトの名無しさん [sage] 2020/02/24(月) 22:21:08.02 ID:ZFXUbFog Ruby で作った。 最初の3つがtrue で、後ろの2つがfalse INT_MAX = "2147483647" def within_int_limit? ( str ) # 範囲内か? res = true # 先頭から続く、0 を除去する while str.start_with? "0" # 先頭の文字が、0 なら str.slice! 0 # 先頭の文字を削除する end len = str.length # 桁数 if len <= 9 then res = true # 長さ、0 も含む elsif 11 <= len then res = false else # 10 桁 10.times do |idx| # 1文字ずつ比較する if str[ idx ] > INT_MAX[ idx ] res = false; break elsif str[ idx ] < INT_MAX[ idx ] res = true; break else # 等しい場合は、ループが続く。res は、true end end end res end [ "00", "123456789", "002147483647", "2147483655", "12345678901" ].each { |str| p within_int_limit? str } http://mevius.5ch.net/test/read.cgi/tech/1573214616/605
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.027s