#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
#include <string.h>
double calculoQtIteracao(double raizA, double raizB, double testeParada) {
}
double calculoC(double raizA, double raizB) {
return (raizA + raizB) / 2;
}
double calculoModuloAB(double raizA, double raizB) {
return abs(raizA
- raizB
); }
double calculoFxF(double raizA, double resultC){
return (pow(raizA
, 3) - 3 * raizA
- 1) * (pow(resultC
, 3) - 3 * resultC
- 1); }
char verificacaoSinal(double resultFxF){
return resultFxF < 0 ? '-' : '+';
}
double trocaAB(double raizA, double raizB, double resultC, char verificacaoSinal) {
return verificacaoSinal == '+' ? resultC : raizA;
//o código aqui estava todo errado, isso ainda está errado, mas é o que executaria
}
void painelPerguntas() {
double raizA = 0, raizB = 0, testeParada = 0;
scanf("%lf", &testeParada
);
double qtIteracoes = calculoQtIteracao(raizA, raizB, testeParada);
double resultC = calculoC(raizA, raizB);
double resultAB = calculoModuloAB(raizA, raizB);
double resultFxF = calculoFxF(raizA, resultC);
char resultSinal = verificacaoSinal(resultFxF);
double resultTrocaAB = trocaAB(raizA, raizB, resultC, resultSinal);
printf("\n N | A | B | C | |A-B| | F(A).F(C) | SINAL"); //o problema estava aqui, falta declarar os vetores
double vetorA[(int)qtIteracoes + 1];
double vetorB[(int)qtIteracoes + 1];
double vetorC[(int)qtIteracoes + 1];
double vetorAB[(int)qtIteracoes + 1];
double vetorFxF[(int)qtIteracoes + 1];
char vetorSinal[(int)qtIteracoes + 1];
//isso também não faz sentido no momento
for (int cont = 0; cont <= qtIteracoes; cont++) {
vetorA[cont] = resultTrocaAB;
vetorB[cont] = resultTrocaAB;
vetorC[cont] = resultC;
vetorAB[cont] = resultAB;
vetorFxF[cont] = resultFxF;
vetorSinal[cont] = resultSinal;
printf("\n%d %f %f %f %f %f %c", cont
, vetorA
[cont
], vetorB
[cont
], vetorC
[cont
], vetorAB
[cont
], vetorFxF
[cont
], vetorSinal
[cont
]); }
}
int main(){
painelPerguntas();
}
I2luY2x1ZGUgPHN0ZGlvL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FyIG9zIHZldG9yZXMKICAgIGRvdWJsZSB2ZXRvckFbKGludClxdEl0ZXJhY29lcyArIDFdOwogICAgZG91YmxlIHZldG9yQlsoaW50KXF0SXRlcmFjb2VzICsgMV07CiAgICBkb3VibGUgdmV0b3JDWyhpbnQpcXRJdGVyYWNvZXMgKyAxXTsKICAgIGRvdWJsZSB2ZXRvckFCWyhpbnQpcXRJdGVyYWNvZXMgKyAxXTsKICAgIGRvdWJsZSB2ZXRvckZ4RlsoaW50KXF0SXRlcmFjb2VzICsgMV07CiAgICBjaGFyIHZldG9yU2luYWxbKGludClxdEl0ZXJhY29lcyArIDFdOwogICAgLy9pc3NvIHRhbWLDqW0gbsOjbyBmYXogc2VudGlkbyBubyBtb21lbnRvCiAgICBmb3IgKGludCBjb250ID0gMDsgY29udCA8PSBxdEl0ZXJhY29lczsgY29udCsrKSB7CiAgICAgICAgdmV0b3JBW2NvbnRdID0gcmVzdWx0VHJvY2FBQjsKICAgICAgICB2ZXRvckJbY29udF0gPSByZXN1bHRUcm9jYUFCOwogICAgICAgIHZldG9yQ1tjb250XSA9IHJlc3VsdEM7CiAgICAgICAgdmV0b3JBQltjb250XSA9IHJlc3VsdEFCOwogICAgICAgIHZldG9yRnhGW2NvbnRdID0gcmVzdWx0RnhGOwogICAgICAgIHZldG9yU2luYWxbY29udF0gPSByZXN1bHRTaW5hbDsKICAgICAgICBwcmludGYoIlxuJWQgJWYgJWYgJWYgJWYgJWYgJWMiLCBjb250LCB2ZXRvckFbY29udF0sIHZldG9yQltjb250XSwgdmV0b3JDW2NvbnRdLCB2ZXRvckFCW2NvbnRdLCB2ZXRvckZ4Rltjb250XSwgdmV0b3JTaW5hbFtjb250XSk7CiAgICB9Cn0KCmludCBtYWluKCl7CiAgICBwYWluZWxQZXJndW50YXMoKTsKfQ==