ayuda con una funcio en dev c++

#1
:eolo:eek:la amigos bakunos tengo un problema en la funcion test1 ya que cuando la mando a llamar no me hace bn las operaciones..:chavo:

me podian ayudar


#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
using namespace std;
struct ejemplo3//ESTRUCTURA DESVIACION
{
float numx[20],numy[20];
struct ejemplo3 *sig;
struct ejemplo3 *ant;
};
ejemplo3 *head=NULL;
ejemplo3 *pnodo=NULL;
ejemplo3 *final=NULL;
float med=0,est=0;
int cant=0,x=0;
float sumx,sumy,sum_mulxy,aux,cuax,cuay,aux2,promx,promy,cuax_prom,aux3,aux4,aux5,aux6,b1,b0,yk,rxy,r2;

int alta()//REGISTRO DE NUMEROS
{
ejemplo3 *tmp;
tmp=head;
tmp=(struct ejemplo3 *)malloc(sizeof(struct ejemplo3));
system("cls");
printf("Cuantos Numeros quieres: ");
scanf("%d",&cant);
system("cls");
for(x=0;x!=cant;x++)
{
printf("Dame el numero en x %d: ",x);
scanf("%f",&tmp->numx[x]);
sumx=sumx+tmp->numx[x];
{
printf("Dame el numero en y %d: ",x);
scanf("%f",&tmp->numy[x]);
sumy=sumy+tmp->numy[x];
}

}
system("cls");
tmp->ant=NULL;
tmp->sig=NULL;
if(head==NULL)
{
head=tmp;
}
else
{
pnodo=head;
while(pnodo->sig!=NULL)//controla bucle de nodos
{
pnodo=pnodo->sig;
}
final=tmp;
pnodo->sig=tmp;
tmp->ant=pnodo;
return 0;
}
}

int test1()
{
ejemplo3 *tmp;
tmp=head;
tmp=(struct ejemplo3 *)malloc(sizeof(struct ejemplo3));
system("cls");


//sumx=sumx+tmp->numx[x];
//sumy=sumy+tmp->numy[x];
aux=tmp->numx[x]*tmp->numy[x];
sum_mulxy=sum_mulxy+aux;
aux2=pow((tmp->numx[x]),2);
cuax=cuax+aux2;
aux3=pow((tmp->numy[x]),2);
cuay=cuay+aux3;
promx=sumx/cant;
promy=sumy/cant;
cuax_prom=pow((promx),2);
b1=(((sum_mulxy)-(cant*promx*promy))/((cuax)-(cant*cuax_prom)));
b0=(promy-(b1*promx));
aux4=(((cant*sum_mulxy)-(sumx*sumy)));
aux5=((cant*cuay)-(pow((sumy),2)))*((cant*cuax)-(pow((sumx),2)));
aux6=sqrt(aux5);
rxy=(aux4/aux6);
r2=pow(rxy ,2);
yk=b0+b1*386;
tmp=tmp->sig;
getch();
system("cls");
return 0;
}
int ver()//VER numeros
{
ejemplo3 *tmp=head;
if(head==NULL)
{
system("color F0");
printf("LISTA VACIA");
}
else
{
while(tmp!=NULL)
{
getch();
system("cls");
printf("los numeros tecleados son:");
for(x=0;x!=cant;x++)
{
printf("\n\nNumeros X %.5f",tmp->numx[x]);
printf("\n\nNumeros Y %.5f",tmp->numy[x]);
}
printf("\n\nLa suma en X es: %.1f\n",sumx);//media
printf("La suma en Y es %.1f \n",sumy);
printf("La suma de la multiplicacion de X y Y es: %.1f \n",sum_mulxy);
printf("Cuadrado de X: %.1f \n",cuax);
printf("Cuadrado de Y: %.1f \n",cuay);
printf("Promedio de X: %.1f\n",promx);
printf("Promedio de y: %.1f\n",promy);
printf("Promedio de X al cuadrado: %.1f\n",cuax_prom);
printf("Resultado de B1: %.6f\n",b1);
printf("Resultado de B0: %.5f\n",b0);
printf("Resultado de YK: %.4f\n",yk);
printf("Resultado de rxy: %.4f\n",rxy);
printf("Resultado de r2: %.4f\n",r2);

tmp=tmp->sig;

}
}
getch();
system("cls");
return 0;
}
/*int desv()
{
desviacion *tmp=head;
system("cls");
printf("Se a Hecho la operacion de la Media y Desviacion Estandar");
float sum1=0,sum2=0,result=0,tmp1=0,tmp2=0;
float N=0;
for(int x=0;x!=cant;x++)
{
sum1+=tmp->num[x];
}
tmp1=cant;
result=sum1/cant;
N=tmp1-1;
for(int x=0;x!=cant;x++)
{
tmp2=0;
tmp2=pow((tmp->num[x]-result),2);
sum2+=tmp2;
}
est=sqrt(sum2/N);
getch();
system("cls");
return 0;
}*/
int menu()
{
int opc=0;
system("color F0");
while (opc!=4)
{ printf("\nSeleccione una opcion:\n1.-Alta de Numeros \n2.-Hacer Operaciones\n3.-Ver Media y Desviacion\n4.-Salir\n\n\n\nPrOgRaMa ElAbOrAdO pOr: SaUl AlEjAnDro_O ");
scanf("%d",&opc);
if (opc==1)alta();
else if (opc==2)test1();
else if (opc==3)ver();
else if (opc==4);
}
}

int main()
{

menu();
system ("cls");
return 0;
}
 
#3
hace una regresion linea
estos son los resultados que quiero obtener de hecho ya los obtuve pero kise hacer una funcion para los resultados y no me funciono
b0 -22.55
b1 1.7279
rxy 0.9545
r2 0.9111
yk 644.429

y estos son los datos que hay que teclear
x1306509915012830295945368961

y16376514116613735513612064331130




 
#4
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
using namespace std;
struct ejemplo3//ESTRUCTURA DESVIACION
{
float numx[20],numy[20];
struct ejemplo3 *sig;
struct ejemplo3 *ant;
};
ejemplo3 *head=NULL;
ejemplo3 *pnodo=NULL;
ejemplo3 *final=NULL;
float med=0,est=0;
int cant=0,x=0;
float sumx,sumy,sum_mulxy,aux,cuax,cuay,promx,promy,cuax_prom,aux2,aux3,aux4,aux5,aux6,b1,b0,yk,rxy,r2;

int alta()//REGISTRO DE NUMEROS
{
ejemplo3 *tmp;
tmp=head;
tmp=(struct ejemplo3 *)malloc(sizeof(struct ejemplo3));
system("cls");
printf("Cuantos Numeros quieres: ");
scanf("%d",&cant);
system("cls");
for(x=0;x!=cant;x++)
{
printf("Dame el numero en x %d: ",x);
scanf("%f",&tmp->numx[x]);
sumx=sumx+tmp->numx[x];
{
printf("Dame el numero en y %d: ",x);
scanf("%f",&tmp->numy[x]);
sumy=sumy+tmp->numy[x];
}
aux=tmp->numx[x]*tmp->numy[x];
sum_mulxy=sum_mulxy+aux;
aux2=pow((tmp->numx[x]),2);
cuax=cuax+aux2;
aux3=pow((tmp->numy[x]),2);
cuay=cuay+aux3;
promx=sumx/cant;
promy=sumy/cant;
cuax_prom=pow((promx),2);
b1=(((sum_mulxy)-(cant*promx*promy))/((cuax)-(cant*cuax_prom)));
b0=(promy-(b1*promx));
aux4=(((cant*sum_mulxy)-(sumx*sumy)));
aux5=((cant*cuay)-(pow((sumy),2)))*((cant*cuax)-(pow((sumx),2)));
aux6=sqrt(aux5);
rxy=(aux4/aux6);
r2=pow(rxy ,2);
yk=b0+b1*386;


}
system("cls");
tmp->ant=NULL;
tmp->sig=NULL;
if(head==NULL)
{
head=tmp;
}
else
{
pnodo=head;
while(pnodo->sig!=NULL)//controla bucle de nodos
{
pnodo=pnodo->sig;
}
final=tmp;
pnodo->sig=tmp;
tmp->ant=pnodo;
return 0;
}
}
int ver()//VER numeros
{
ejemplo3 *tmp=head;
if(head==NULL)
{
system("color F0");
printf("LISTA VACIA");
}
else
{
while(tmp!=NULL)
{
getch();
system("cls");
printf("los numeros tecleados son:");
for(x=0;x!=cant;x++)
{
printf("\n\nNumeros X %.5f",tmp->numx[x]);
printf("\n\nNumeros Y %.5f",tmp->numy[x]);
}
printf("\n\nLa suma en X es: %.1f\n",sumx);//media
printf("La suma en Y es %.1f \n",sumy);
printf("La suma de la multiplicacion de X y Y es: %.1f \n",sum_mulxy);
printf("Cuadrado de X: %.1f \n",cuax);
printf("Cuadrado de Y: %.1f \n",cuay);
printf("Promedio de X: %.1f\n",promx);
printf("Promedio de y: %.1f\n",promy);
printf("Promedio de X al cuadrado: %.1f\n",cuax_prom);
printf("Resultado de B1: %.6f\n",b1);
printf("Resultado de B0: %.5f\n",b0);
printf("Resultado de YK: %.4f\n",yk);
printf("Resultado de rxy: %.4f\n",rxy);
printf("Resultado de r2: %.4f\n",r2);

tmp=tmp->sig;

}
}
getch();
system("cls");
return 0;
}
int menu()
{
int opc=0;
system("color F0");
while (opc!=4)
{ printf("\nSeleccione una opcion:\n1.-Alta de Numeros \n2.-Hacer Operaciones\n3.-Ver Media y Desviacion\n4.-Salir\n\n\n\nPrOgRaMa ElAbOrAdO pOr: SaUl AlEjAnDro_O ");
scanf("%d",&opc);
if (opc==1)alta();
//else if (opc==2)desv();
else if (opc==3)ver();
else if (opc==4);
}
}

int main()
{

menu();
system ("cls");
return 0;
}
 
Arriba