Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <stdio.h>
- #include "functions.h"
- int main() {
- Item* start = NULL;
- for (int i = 0; i < 5; i++) {
- addFirstItem(&start, i + 5);
- }
- showItems(start, 5);
- //int x = 0;
- //int x = searchItem(start, 7);
- Item* tmp = searchItem(start, 7);
- if (tmp != NULL)
- printf("\nThe value %d has been found.\n", tmp->value);
- if (removeAllItems(start) == 1)
- printf("All elements in list have been removed.\n");
- return 0;
- }*/
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct Muscle{
- int selected;
- char * label;
- struct Muscle * next;
- } Muscle;
- Muscle * searchMuscle(Muscle * start,const char * search);
- typedef struct Exercice{
- char * name;
- char * description;
- Muscle * muscleTest;
- struct Exercice * next;
- } Exercice;
- int addExercice(Exercice ** start, Muscle * start2,char * name, char * description, char * muscle){
- Exercice * inter=NULL;
- inter=malloc(sizeof(Exercice));
- if(inter==NULL) return 0;
- inter->description=description;
- inter->name=name;
- inter->muscleTest=searchMuscle(start2,muscle);
- printf(" name : %s ",name);
- printf(" description : %s \n",description);
- inter->next=*start;
- *start=inter;
- return 1 ;
- }
- int addMuscle(Muscle ** start , int selected, char * label ){
- Muscle * inter;
- inter=malloc(sizeof(Muscle));
- if(inter==NULL) return 0;
- inter->selected=selected;
- inter->label=label;
- inter->next=*start;
- *start=inter;
- printf(" selected : %d ",selected);
- printf(" label : %s \n",label);
- return 1 ;
- }
- Muscle * deleteMuscle(Muscle* start){
- if (start == NULL) return NULL;
- Muscle * tmp;
- tmp=start;
- free(start);
- return tmp;
- }
- int showMuscle(Muscle* start, int n) {
- // Muscle* tmp = start;
- if (start == NULL) return 0;
- if(n==0) {
- while(start->next!=NULL) {
- if(start->selected==1){
- printf("%s \n", start->label);
- }
- start = start->next;
- }
- }else{
- while(n>0){
- if(start->selected==1){
- printf("%s \n", start->label);
- }
- start = start->next;
- n--;
- }
- }
- return 1;
- }
- int showExo(Exercice* start, int n) {
- // Muscle* tmp = start;
- if (start == NULL) return 0;
- if(n==-1) {
- do{
- if(start->muscleTest->selected==1){
- printf("%s : ", start->name);
- printf("%s \n", start->muscleTest->label);
- }
- start = start->next;
- }while(start!=NULL) ;
- }else{
- while(n>0){
- // if(start->selected==1){
- printf("%s : ", start->name);
- printf("%s \n", start->muscleTest->label);
- // }
- start = start->next;
- n--;
- }
- }
- return 1;
- }
- void function(void){
- printf("pute");
- }
- Muscle * searchMuscle(Muscle * start,const char * search){
- while(start!=NULL){
- if( start->label==search){
- return start;
- }
- start=start->next;
- }
- return NULL;
- }
- void function2(int x, int y ,char * titre, void (*nomdelafonction)(void)){
- printf("%d",x);
- printf("%d",y);
- printf("%s",titre);
- }
- int main(int argc, char ** argv){
- Muscle * start=NULL;
- addMuscle(&start,1, "jambe" );
- addMuscle(&start,1, "dos" );
- addMuscle(&start,0, "pec" );
- addMuscle(&start,1, "epaule" );
- addMuscle(&start,1, "bras" );
- Exercice * start2=NULL;
- addExercice(&start2,start,"a","aDef","jambe");
- addExercice(&start2,start,"b","bDef","dos");
- addExercice(&start2,start,"c","cDef","pec");
- addExercice(&start2,start,"d","dDef","epaule");
- addExercice(&start2,start,"e","eDef","bras");
- showExo (start2, -1);
- /*
- printf("test123 : %d", start2->muscleTest);
- printf("test123 : %s", start2->name);
- printf("test123 : %s", start2->description);
- /*
- addExercice(&start2,"developper couche", "allonge avec une barre",&start->bras );
- addExercice(&start2,"pompe", "au sol","bras" );
- showMuscle (start2, 0);
- */
- /*
- void (* pointeurSurFonction)(int, int, char *, void);
- pointeurSurFonction=function2;
- (*pointeurSurFonction)(1,2,"test",function);
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement