소개글
개발 언어 : C
long형으로도 표현할수 없을정도의 아주 긴 숫자의 덧셈을 하는 프로그램입니다.
정수형으로 덧셈을 할수 없기 때문에 모두 문자열로 받아서 덧셈을 합니다.
덧셈시 carry가 발행했을 경우의 처리와 자릿수가 서로 다른 두 수의 덧셈처리에 유의해야
하는 문제이구요, 그부분에 대한 처리를 모두 하였습니다.
컴파일 실행환경
Turbo C / Microsoft Visual c++
본문내용
#include <stdio.h>
#include <string.h>
#define MAX(x,y) ((x) > (y) ? (x) : (y))
struct integer {
int size;
char d[1000];
};
void read_int (struct integer *x);
void add_int (struct integer x, struct integer y, struct integer *z);
void print_int(struct integer x);
main() {
struct integer a, b, c;
printf("Enter the first number : ");
read_int(&a);
printf("Enter the second number : ");
read_int(&b);
add_int(a, b, &c);
print_int(a);
printf(" + ");
print_int(b);
printf(" = ");
print_int(c);
printf("\n");
참고 자료
없음