ぼるじょあがC/C++の宿題を片づけますYO! 47代目

このエントリーをはてなブックマークに追加
287デフォルトの名無しさん
>>282
#include <stdio.h>
#define DIGITS_MAX 200

int main() {
  unsigned char digits[DIGITS_MAX], endPos = 0;
  int i, j, num, mul, pos, tmpAns, carry;
  digits[0] = '1';
  for (i = 2; i <= 100; i++) {
    num = i; carry = 0; tmpAns = i / 10;
    for (pos = 0, tmpAns = i; tmpAns != 0; tmpAns /= 10, pos++);
    while (--pos >= 0) {
      mul = i;
      for (j = 0; j < pos; j++, mul /= 10);
      for (j = pos; j <= endPos; j++) {
        tmpAns = (digits[j] - '0') * mul + carry;
        carry = tmpAns / 10;
        digits[j] = '0' + (tmpAns % 10);
      }
      while (carry != 0) {
        digits[++endPos] = '0' + (carry % 10);
        carry /= 10;
      }
    }
    printf("%d! = ", i);
    for (j = endPos; j >= 0; j--) {
      printf("%c", digits[j]);
    }
    printf("\n");
  }
}
288287:2005/07/08(金) 04:55:31
> unsigned char digits[DIGITS_MAX], endPos = 0;
> int i, j, num, mul, pos, tmpAns, carry;



  unsigned char digits[DIGITS_MAX];
  int i, j, num, mul, pos, tmpAns, carry, endPos = 0;

と直してくれい。