otra forma de hacer codigo
Publicado por diego (7 intervenciones) el 22/11/2014 01:48:34
hola alguien me podria ayudar en buscar otra forma de hacer este codigo
el codigo esta bueno pero tengo que lograr realizarlo de otra manera
se agradece de antemano las respuestas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
main(void)
{ float aux;
float sum;
float err;
float ant;
float pre = 10;
float x=0.5;
printf("\t VANTERIOR\t VACTUAL\t VERROR\n ");
for (float k=1;k<160;k++)
{ ant=sum;
sum=pow(-1,k+1)*pow(x,k)/k;
sum=sum+aux;
aux=sum;
err=fabs(ant-sum);
if(err<pow(10,-pre))
break;
printf("\t%10.8f\t%10.8f\t%10.8f \n", ant, sum, err); }
getchar(); }
el codigo esta bueno pero tengo que lograr realizarlo de otra manera
se agradece de antemano las respuestas
Valora esta pregunta


0