C/C++の宿題片付けま ..
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に続く
次ページ最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5337日前に更新/150 KB
担当:undef