Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Captura de pantalla de 2020-09-10 10-45-35.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions archivos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
//
// archivos.c
//
// Created by Sergio Medina Galàn and Gustavo Luna Maya on 12/09/2020
//
//


/*Include standard headers*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

/*Include modules header we directly invoke here: */
#include"archivos.h"

/**
* Initialises a new file pointer identified via its name and mode.
* @param
* name (char *):
* Name of the file
* mode (char *):
* Mode of file to be opened {r, rb, a, ab, w, wb}
*
* @return FILE * opened_file.
*/
extern FILE * file_new( char * name, char *mode)
{
FILE *fp;
fp = fopen(name,mode);
return fp;
}


/**
* Writes a bidimensional buffer array into a file.
* @param
* file (FILE *):
* Storage file
* columns (size_t ):
* length of the buffer array
* buff [ ][columns] (long double):
* RAM matrix
* rows (size_t):
* width of the storage buffer
*
* @return void.
*/
extern void file_num_write(FILE * file, size_t columns, long double buff[] [columns], size_t rows)
{
char linea[10];
sprintf(linea,"%zu %zu \n",rows,columns);
// fputs (linea, file);
for (size_t i =0; i<rows; i++){
linea[0] = '\0';


char buffer[8];
for(int j =0; j<=2; j++){
fprintf(file,"%1.5Lf \t",buff[i][j]);

strcat(linea,buffer);
}
fprintf(file,"\n");
int len = strlen(linea);
linea[len-1] = '\n';
fputs(linea,file);

}
}


73 changes: 73 additions & 0 deletions archivos.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
//
// files.c
//
// Created by Sergio Medina Galàn and Gustavo Luna Maya on 12/09/2020
//
//


/*Include standard headers*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

/*Include modules header we directly invoke here: */
#include"files.h"

/**
* Initialises a new file pointer identified via its name and mode.
* @param
* name (char *):
* Name of the file
* mode (char *):
* Mode of file to be opened {r, rb, a, ab, w, wb}
*
* @return FILE * opened_file.
*/
extern FILE * file_new( char * name, char *mode)
{
FILE *fp;
fp = fopen(name,mode);
return fp;
}


/**
* Writes a bidimensional buffer array into a file.
* @param
* file (FILE *):
* Storage file
* columns (size_t ):
* length of the buffer array
* buff [ ][columns] (long double):
* RAM matrix
* rows (size_t):
* width of the storage buffer
*
* @return void.
*/
extern void file_num_write(FILE * file, size_t columns, long double buff[] [columns], size_t rows)
{
char linea[10];
sprintf(linea,"%zu %zu \n",rows,columns);
// fputs (linea, file);
for (size_t i =0; i<rows; i++){
linea[0] = '\0';


char buffer[8];
for(int j =0; j<=2; j++){
fprintf(file,"%1.5Lf \t",buff[i][j]);

strcat(linea,buffer);
}
fprintf(file,"\n");
int len = strlen(linea);
linea[len-1] = '\n';
fputs(linea,file);

}
}


58 changes: 58 additions & 0 deletions archivos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// archivos.h
//
//
// Created by Cesar Angeles on 07/09/2020.
//

#ifndef files_h
#define files_h

#include <stdio.h>

#ifdef files_IMPORT
#define EXTERN
#else
#define EXTERN extern
#endif


/* files.h -- Function prototypes */

/**
* Instanciates a new file pointer identified via its name and mode.
* @param
* name (char *):
* Name of the file
* mode (char *):
* Mode of file to be opened {r, rb, a, ab, w, wb}
*
* @return FILE * opened_file.
*/
EXTERN FILE * file_new(char *name, char *mode);



/**
* Writes a bidimensional buffer array into a file.
* @param
* file (FILE *):
* Storage file
* columns (size_t ):
* length of the buffer array
* buff [ ][columns] (long double):
* RAM matrix
* rows (size_t):
* width of the storage buffer
*
* @return void.
*/

EXTERN void file_num_write(FILE * file, size_t columns, long double buff[] [columns], size_t rows);

#undef files_IMPORT
#undef EXTERN



#endif /* files_h */
58 changes: 58 additions & 0 deletions archivos.h~
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// files.h
//
//
// Created by Cesar Angeles on 07/09/2020.
//

#ifndef files_h
#define files_h

#include <stdio.h>

#ifdef files_IMPORT
#define EXTERN
#else
#define EXTERN extern
#endif


/* files.h -- Function prototypes */

/**
* Instanciates a new file pointer identified via its name and mode.
* @param
* name (char *):
* Name of the file
* mode (char *):
* Mode of file to be opened {r, rb, a, ab, w, wb}
*
* @return FILE * opened_file.
*/
EXTERN FILE * file_new(char *name, char *mode);



/**
* Writes a bidimensional buffer array into a file.
* @param
* file (FILE *):
* Storage file
* columns (size_t ):
* length of the buffer array
* buff [ ][columns] (long double):
* RAM matrix
* rows (size_t):
* width of the storage buffer
*
* @return void.
*/

EXTERN void file_num_write(FILE * file, size_t columns, long double buff[] [columns], size_t rows);

#undef files_IMPORT
#undef EXTERN



#endif /* files_h */
50 changes: 50 additions & 0 deletions funcionesfibo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
//
// funcionesfibo.c
//
// Created by Sergio Medina Galàn and Gustavo Luna Maya on 12/09/2020
//
//


/*Inlcude standard headers*/
#include <stdio.h>

/*Inlude modules header we directly invoke here: */
#include "funcionesfibo.h"


/**
* Returns the value of the fibonacci sequence at index n calculated recursively
* @param
* n (long long int):
* Index of the fibonacci sequence
* @return long long int value
*/
extern long long int Sequences_rfibo(long long int n)
{
if (n==0 || n ==1)
return n;
else
return Sequences_rfibo(n-2) + Sequences_rfibo(n-1);
}

/**
* Returns the value of the fibonacci sequence at index n calculated sequentially
* @param
* n (long long int):
* Index of the fibonacci sequence
* @return long long int value
*/
extern long long int Sequences_sfibo(long long int n)
{
long long int p=0,s=1,u;
int i;
for(i=0; i<=n;i++){
u=p+s;
p=s;
s=u;

}
return u;
}
50 changes: 50 additions & 0 deletions funcionesfibo.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
//
// Sequences.c
//
// Created by Sergio Medina Galàn and Gustavo Luna Maya on 12/09/2020
//
//


/*Inlcude standard headers*/
#include <stdio.h>

/*Inlude modules header we directly invoke here: */
#include "Sequences.h"


/**
* Returns the value of the fibonacci sequence at index n calculated recursively
* @param
* n (long long int):
* Index of the fibonacci sequence
* @return long long int value
*/
extern long long int Sequences_rfibo(long long int n)
{
if (n==0 || n ==1)
return n;
else
return Sequences_rfibo(n-2) + Sequences_rfibo(n-1);
}

/**
* Returns the value of the fibonacci sequence at index n calculated sequentially
* @param
* n (long long int):
* Index of the fibonacci sequence
* @return long long int value
*/
extern long long int Sequences_sfibo(long long int n)
{
long long int p=0,s=1,u;
int i;
for(i=0; i<=n;i++){
u=p+s;
p=s;
s=u;

}
return u;
}
Loading