Skip to content

Instantly share code, notes, and snippets.

@lefty313
lefty313 / file_operation.c
Created June 11, 2011 12:30
file_operation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void print_char_vector(char * array)
{
int i;
printf("\n");
for (i = 0; i < strlen(array); ++i) printf("\%c",array[i]);
}
@lefty313
lefty313 / string_manipulation.c
Created June 9, 2011 18:59
string_manipulation
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char * create_char_vector(int i)
{
char *vector;
vector = (char *) calloc(i + 1,sizeof(char *));
vector[i+1] = 0;
@lefty313
lefty313 / pointer_matrix.c
Created June 1, 2011 19:21
pointer_matrix_operation
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int ** allocate_memory(int w, int k)
{
int **tab, i;
tab = (int **) calloc(w, sizeof(int*));
for ( i = 0; i < w; ++i)
@lefty313
lefty313 / struct_matrix_operation.c
Created June 1, 2011 19:17
Memory allocation with struct
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct Matrix {
int w;
int k;
int **container;
};
@lefty313
lefty313 / gist:986688
Created May 23, 2011 13:24
trapezoidal integration
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
/*
Wedlug wolfram alfa pole zaznaczone przez ta calke od 2 do 4 wynosi w przyblizeniu = 65.8758
http://www.wolframalpha.com/input/?i=integral+x^2+%2B+e^x+from+2+to+4
Aby uzyskac taki wynik w moim algorytmie nalezy ustawic dokladnosc calkowania na 350
Funkcja dla ktorej obliczamy calke