C/C++の宿題片付けます 126代目
■ このスレッドは過去ログ倉庫に格納されています
0302デフォルトの名無しさん
2009/05/26(火) 23:42:15#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に続く
■ このスレッドは過去ログ倉庫に格納されています