2009-12-22から1日間の記事一覧

エラー握りつぶし

ありがちダメなコードのダメな理由を書くコーナー。 #include <stdlib.h> #include <math.h> #include <stdio.h> int mysqrt(int x) { if (x < 0) { return 0; } else { return (int)sqrt(x); } } int main() { printf("%d\n", mysqrt(4)); printf("%d\n", mysqrt(1)); printf("%d\n", m</stdio.h></math.h></stdlib.h>…