C/C++の宿題片付けます 126代目 at TECH
[2ch|▼Menu]
302:デフォルトの名無しさん
09/05/26 23:42:15
>>291
#include <stdio.h>
#include <stdlib.h>
typedef struct tag_LINT{
  int sz_array;
  int* value;
} LINT;
LINT* create_lint(int keta){ // size:桁
  LINT* lint = (LINT*)malloc(sizeof(LINT));
  lint->sz_array = keta / 4 + 1;
  lint->value = (int*)calloc( sizeof(int), lint->sz_array);
  return lint;
}
LINT* copy_lint(LINT* lint){
  LINT* copy = (LINT*)malloc(sizeof(LINT));
  copy->sz_array = lint->sz_array;
  copy->value = (int*)calloc( sizeof(int), lint->sz_array);
  return copy;
}
LINT* mul_lint_int(LINT* l_num, int r_num){
  int carry = 0;
  //for (int i=l_num->sz_array-1; i>=0; i--){
  for (int i=0; i < l_num->sz_array; i++){
        int tmp = l_num->value[i] * r_num + carry;
    l_num->value[i] = tmp % 10000;
    carry = tmp / 10000;
  }
  return l_num;
}
>>303に続く


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5337日前に更新/150 KB
担当:undef