All pastes #729082 Raw Edit

Podre

public text v1 · immutable
·published 2007-10-07 17:05 UTC
rendered paste body
void Calcula_produto (No *p1,No *p2,No *result) {
	No *novo_no,
	   *aux1=p1->prox,
	   *aux2=p2->prox,
	   *aux_res=result;

	if (aux1->exp >= aux2->exp) {
		while (aux1->exp!=-1) {
			aux2=p2->prox;
			printf("OK 2\n");
			while (aux2->exp!=-1) {
				printf("OK 3\n");
				novo_no=(No *)malloc(sizeof(No));
				if (novo_no==NULL)
					printf("DEU PAU\n");
				printf("EXP: %d\n",aux2->exp);
				novo_no->coef= aux1->coef * aux2->coef;

				novo_no->exp= aux1->exp + aux2->exp;
				aux_res->prox=novo_no;
				aux_res=novo_no;
				aux2=aux2->prox;
			}
			aux1=aux1->prox;
		}
	}
	else {
		while (aux2->exp!=-1) {
			aux1=p1->prox;
			while (aux1->exp!=-1) {
				novo_no=(No *)malloc(sizeof(No));
				novo_no->coef= aux1->coef * aux2->coef;
				novo_no->exp= aux1->exp + aux2->exp;
				aux_res->prox=novo_no;
				aux_res=novo_no;
				aux1=aux1->prox;
			}
			aux2=aux2->prox;
		}
	}
	aux_res->prox=result;
}