2013

Prueba 2

Menu Principal

Compile como:

          $gcc prueba2.c -o ejec -std=c99 -lm
include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

int main()
{
//abrir archivos
  FILE * ht;
  FILE * vt;
  double t[20926];
  double h[20926];
  ht=fopen("tvsh.txt","r");
  vt=fopen("vvst.txt","w");
  if(!ht)
   {
     printf("Error no se encuentra el fichero\n");
     return 1;
   }
  if(!vt)
   {
     printf("Error no se encuentra el fichero\n");
     return 1;
   }
  for(int i=0;i<20926;i++)
   {
    fscanf(ht,"%lf %lf",&t[i],&h[i]);
//    printf("%lf \t %lf \n",t[i],h[i]);
   }
//calculo velocidad inicial eje y
   double v0y=(h[1]-h[0])/(t[1]-t[0]);
   double v0=2*v0y/sqrt(2);
//   printf("%lf \n",v0);
// Calculo alcance maximo
//   printf("%lf \n",2*v0y/9.8);
   double xmax=2.0*v0y*v0*cos(45.0*PI/180.0)/9.8;
   printf("%lf \n",xmax);
// Calculo de velocidad
   double v=0.0;
   double tmedio=0.0;
   for(int j=0;j<20925;j++)
    {
     v=(h[j+1]-h[j])/(t[j+1]-t[j]);
     tmedio=(t[j+1]-t[j])/2+t[j];
//     printf("%lf \t %lf \n", tmedio,v);
     fprintf(vt,"%lf \t %lf \n",tmedio,v);
    }
  fclose(ht);
  fclose(vt);
  return 0;
}

University

Personal

edit SideBar