Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

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

@ -0,0 +1,59 @@
#include <stdlib.h>
#include <stdio.h>
typedef struct node{
char value;
struct node* next;
} node;
typedef struct charList{
node* first;
int size;
} charList;
charList createList(){
charList foo = {.first = NULL, .size = 0};
return foo;
}
int addEl(charList* list, char c){
if(list != NULL){
node* foo = (node*)malloc(sizeof(node));
if(foo == NULL) return -1;
foo->value = c; foo->next = NULL;
if(list->first == NULL){
list->first = foo;
}else{
node* it= list->first;
while(it->next != NULL)it = it->next;
it->next = foo;
}
list->size = list->size+1;
return 0;
}else return -1;
}
int removeEl(charList* list, int index){
if(list != NULL && list->size > index){
node* it = list->first;
for(int i = 0; i < index-1; i++) it = it->next;
node* el = it->next;
it->next = el->next;
free(el);
list->size--;
return 0;
}else return -1;
}
char getEl(charList* list, int index){
if(list != NULL && list->size > index){
node* it = list->first;
for(int i = 0; i < index; i++) it = it->next;
return it->value;
}else return '\0';
}
static void cleanHelp(node* el){
if(el != NULL){
if(el->next != NULL) cleanHelp(el->next);
free(el);
}
}
void clean(charList* list){
cleanHelp(list->first);
list->size = 0;
}

View file

@ -1 +1 @@
var staticArray := new int[]{1, 2, 3};
var staticArray := new int[]::(1, 2, 3);

View file

@ -0,0 +1,18 @@
HAI 1.4
BTW declaring array
I HAS A array ITZ A BUKKIT
BTW store values in array
array HAS A one ITZ 1
array HAS A two ITZ 2
array HAS A three ITZ 3
array HAS A string ITZ "MEOW"
OBTW
there is no way to get an element of an array at a specified index in LOLCODE
therefore, you can't really iterate through an array
TLDR
BTW get the element of array
VISIBLE array'Z one
VISIBLE array'Z two
VISIBLE array'Z three
VISIBLE array'Z string
KTHXBYE