June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,49 @@
/*Abhishek Ghosh, 15th November 2017*/
#include<stdio.h>
typedef struct{
int a;
}layer1;
typedef struct{
layer1 l1;
float b,c;
}layer2;
typedef struct{
layer2 l2;
layer1 l1;
int d,e;
}layer3;
void showCake(layer3 cake){
printf("\ncake.d = %d",cake.d);
printf("\ncake.e = %d",cake.e);
printf("\ncake.l1.a = %d",cake.l1.a);
printf("\ncake.l2.b = %f",cake.l2.b);
printf("\ncake.l2.l1.a = %d",cake.l2.l1.a);
}
int main()
{
layer3 cake1,cake2;
cake1.d = 1;
cake1.e = 2;
cake1.l1.a = 3;
cake1.l2.b = 4;
cake1.l2.l1.a = 5;
printf("Cake 1 is : ");
showCake(cake1);
cake2 = cake1;
cake2.l2.b += cake2.l2.l1.a;
printf("\nCake 2 is : ");
showCake(cake2);
return 0;
}

View file

@ -0,0 +1,92 @@
/*Abhishek Ghosh, 15th November 2017*/
#include<stdlib.h>
#include<stdio.h>
typedef struct elem{
int data;
struct elem* next;
}cell;
typedef cell* list;
void addToList(list *a,int num){
list temp, holder;
if(*a==NULL){
*a = (list)malloc(sizeof(cell));
(*a)->data = num;
(*a)->next = NULL;
}
else{
temp = *a;
while(temp->next!=NULL)
temp = temp->next;
holder = (list)malloc(sizeof(cell));
holder->data = num;
holder->next = NULL;
temp->next = holder;
}
}
list copyList(list a){
list b, tempA, tempB, temp;
if(a!=NULL){
b = (list)malloc(sizeof(cell));
b->data = a->data;
b->next = NULL;
tempA = a->next;
tempB = b;
while(tempA!=NULL){
temp = (list)malloc(sizeof(cell));
temp->data = tempA->data;
temp->next = NULL;
tempB->next = temp;
tempB = temp;
tempA = tempA->next;
}
}
return b;
}
void printList(list a){
list temp = a;
while(temp!=NULL){
printf("%d,",temp->data);
temp = temp->next;
}
printf("\b");
}
int main()
{
list a,b;
int i;
for(i=1;i<=5;i++)
addToList(&a,i);
printf("List a is : ");
printList(a);
b = copyList(a);
free(a);
printf("\nList a destroyed, List b is : ");
printList(b);
return 0;
}