#/*********************************************************** # isbn.rb -- ISBN番号 #***********************************************************/ d = [] printf("ISBN book number: ") for i in 1..10 c = $stdin.getc if (c >= ?0 && c <= ?9) d[i] = c - ?0 elsif (i == 10 && (c == ?x || c == ?X)) d[i] = 10 else exit 1 end end d[0] = 0 for i in 1..10; d[i] += d[i - 1]; end for i in 1..10; d[i] += d[i - 1]; end if (d[10] % 11 == 0) puts("Valid"); # 有効な番号 else puts("Wrong"); # 無効な番号 end exit 0