new tasks

This commit is contained in:
Ingy döt Net 2013-04-09 00:46:50 -07:00
parent 2a4d27cea0
commit 80737d5a6a
1194 changed files with 15353 additions and 1 deletions

1
Task/Arrays/C/arrays-2.c Normal file
View file

@ -0,0 +1 @@
#define MYFLOAT_SIZE (sizeof(myFloats)/sizeof(myFloats[0]))

5
Task/Arrays/C/arrays-3.c Normal file
View file

@ -0,0 +1,5 @@
long a2D_Array[3][5]; /* 3 rows, 5 columns. */
float my2Dfloats[][3] = {
1.0, 2.0, 0.0,
5.0, 1.0, 3.0 };
#define FLOAT_ROWS (sizeof(my2Dfloats)/sizeof(my2dFloats[0]))

11
Task/Arrays/C/arrays-4.c Normal file
View file

@ -0,0 +1,11 @@
int numElements = 10;
int *myArray = malloc(sizeof(int) * numElements); /* array of 10 integers */
if ( myArray != NULL ) /* check to ensure allocation succeeded. */
{
/* allocation succeeded */
/* at the end, we need to free the allocated memory */
free(myArray);
}
/* calloc() additionally pre-initializes to all zeros */
short *myShorts = calloc( numElements, sizeof(short)); /* array of 10 */
if (myShorts != NULL)....

2
Task/Arrays/C/arrays-5.c Normal file
View file

@ -0,0 +1,2 @@
myArray[0] = 1;
myArray[1] = 3;

1
Task/Arrays/C/arrays-6.c Normal file
View file

@ -0,0 +1 @@
printf("%d\n", myArray[1]);

3
Task/Arrays/C/arrays-7.c Normal file
View file

@ -0,0 +1,3 @@
*(array + index) = 1;
printf("%d\n", *(array + index));
3[array] = 5;

10
Task/Arrays/C/arrays-8.c Normal file
View file

@ -0,0 +1,10 @@
#define XSIZE 20
double *kernel = malloc(sizeof(double)*2*XSIZE+1);
if (kernel) {
kernel += XSIZE;
for (ix=-XSIZE; ix<=XSIZE; ix++) {
kernel[ix] = f(ix);
....
free(kernel-XSIZE);
}
}

3
Task/Arrays/C/arrays-9.c Normal file
View file

@ -0,0 +1,3 @@
int *array = malloc (sizeof(int) * 20);
....
array = realloc(array, sizeof(int) * 40);

2
Task/Arrays/C/arrays.c Normal file
View file

@ -0,0 +1,2 @@
int myArray2[10] = { 1, 2, 0 }; /* the rest of elements get the value 0 */
float myFloats[] ={1.2, 2.5, 3.333, 4.92, 11.2, 22.0 }; /* automatically sizes */