aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
This commit is contained in:
parent
4144375bae
commit
2a64ba1c67
@ -51,21 +51,25 @@ unsigned short int retirer_premier(maillon* premier)
|
|||||||
maillon* postp = (maillon*) malloc(sizeof(maillon));
|
maillon* postp = (maillon*) malloc(sizeof(maillon));
|
||||||
postp = premier -> suivant;
|
postp = premier -> suivant;
|
||||||
unsigned short int chiffre = premier -> valeur;
|
unsigned short int chiffre = premier -> valeur;
|
||||||
free(premier);
|
premier -> valeur = postp -> valeur;
|
||||||
|
premier ->suivant = postp -> suivant;
|
||||||
|
free(postp);
|
||||||
return chiffre;
|
return chiffre;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short int retirer_dernier(maillon* premier)
|
unsigned short int retirer_dernier(maillon* premier)
|
||||||
{
|
{
|
||||||
|
unsigned short int output;
|
||||||
maillon* p = (maillon*) malloc(sizeof(maillon));
|
maillon* p = (maillon*) malloc(sizeof(maillon));
|
||||||
maillon* anteP = (maillon*) malloc(sizeof(maillon));
|
maillon* anteP = (maillon*) malloc(sizeof(maillon));
|
||||||
for(p = premier; p != NULL; p = p->suivant)
|
for(p = premier; p != NULL; p = p->suivant)
|
||||||
{
|
{
|
||||||
if(p->suivant==NULL)
|
if(p->suivant==NULL)
|
||||||
{
|
{
|
||||||
anteP ->suivant=NULL;
|
anteP ->suivant = NULL;
|
||||||
|
output = p -> valeur;
|
||||||
free(p);
|
free(p);
|
||||||
return p->valeur;
|
return output;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -100,7 +104,6 @@ int main(int argc, char const *argv[])
|
|||||||
number = (rand() % (999 - 111 + 1)) + 111;
|
number = (rand() % (999 - 111 + 1)) + 111;
|
||||||
mail = ajouter_debut(mail,number);
|
mail = ajouter_debut(mail,number);
|
||||||
}
|
}
|
||||||
afficher(mail);
|
|
||||||
|
|
||||||
int max = mail -> valeur;
|
int max = mail -> valeur;
|
||||||
for(maillon* p = mail; p != NULL; p = p->suivant)
|
for(maillon* p = mail; p != NULL; p = p->suivant)
|
||||||
@ -110,7 +113,7 @@ int main(int argc, char const *argv[])
|
|||||||
max = p->valeur;
|
max = p->valeur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("le max est: %d \n", max);
|
/*printf("le max est: %d \n", max);
|
||||||
printf("la liste sans le dernier nombre:");
|
printf("la liste sans le dernier nombre:");
|
||||||
retirer_dernier(mail);
|
retirer_dernier(mail);
|
||||||
afficher(mail);
|
afficher(mail);
|
||||||
@ -123,10 +126,35 @@ int main(int argc, char const *argv[])
|
|||||||
printf("suppresion du premier element: \n");
|
printf("suppresion du premier element: \n");
|
||||||
retirer_premier(mail);
|
retirer_premier(mail);
|
||||||
afficher(mail);
|
afficher(mail);
|
||||||
/*printf("cycle mais dans lautre sens:\n");
|
printf("cycle mais dans lautre sens:\n");
|
||||||
mail=circulerAnti(mail);
|
mail=circulerAnti(mail);
|
||||||
afficher(mail);*/
|
afficher(mail);*/
|
||||||
|
|
||||||
|
afficher(mail);
|
||||||
|
int rotation;
|
||||||
|
printf("choisissez une rotation: \n");
|
||||||
|
scanf("%d",&rotation);
|
||||||
|
if(rotation > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rotation; ++i)
|
||||||
|
{
|
||||||
|
mail=circuler(mail);
|
||||||
|
}
|
||||||
|
afficher(mail);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
if (rotation < 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (-1*rotation); ++i)
|
||||||
|
{
|
||||||
|
mail=circulerAnti(mail);
|
||||||
|
}
|
||||||
|
afficher(mail);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
afficher(mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
72
DEV1.1/TP14/rainbow.c
Normal file
72
DEV1.1/TP14/rainbow.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include <graph.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
struct mail {
|
||||||
|
unsigned char r;
|
||||||
|
unsigned char v;
|
||||||
|
unsigned char b;
|
||||||
|
struct mail* suivant;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct mail maillon;
|
||||||
|
|
||||||
|
void txt(int x, int y,char texte[],maillon* rainbow)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
couleur c;
|
||||||
|
for (int i = 0; i < strlen(texte); ++i)
|
||||||
|
{
|
||||||
|
*ptr = texte[i];
|
||||||
|
c=CouleurParComposante(rainbow->r,rainbow->v,rainbow->b);
|
||||||
|
ChoisirCouleurDessin(c);
|
||||||
|
EcrireTexte(x,y,ptr,2);
|
||||||
|
rainbow=rainbow->suivant;
|
||||||
|
x+=TailleChaineEcran(ptr,2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maillon* ajouter_debut(maillon* premier,unsigned char rouge,unsigned char vert,unsigned char bleu)
|
||||||
|
{
|
||||||
|
maillon* p = (maillon*) malloc(sizeof(maillon));
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
p->suivant = premier;
|
||||||
|
p->r = rouge;
|
||||||
|
p->v = vert;
|
||||||
|
p->b = bleu;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[])
|
||||||
|
{
|
||||||
|
maillon *rainbow = malloc(sizeof(maillon));
|
||||||
|
|
||||||
|
rainbow->r = 255;
|
||||||
|
rainbow->v = 0;
|
||||||
|
rainbow->b = 0;
|
||||||
|
maillon* end;
|
||||||
|
end = rainbow;
|
||||||
|
rainbow = ajouter_debut(rainbow,255,144,0);
|
||||||
|
rainbow = ajouter_debut(rainbow,255,255,50);
|
||||||
|
rainbow = ajouter_debut(rainbow,0,235,30);
|
||||||
|
rainbow = ajouter_debut(rainbow,0,255,240);
|
||||||
|
rainbow = ajouter_debut(rainbow,0,81,255);
|
||||||
|
rainbow = ajouter_debut(rainbow,136,0,255);
|
||||||
|
rainbow = ajouter_debut(rainbow,220,0,255);
|
||||||
|
rainbow = ajouter_debut(rainbow,255,0,144);
|
||||||
|
end ->suivant = rainbow;
|
||||||
|
|
||||||
|
char blablabla[1]="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||||
|
|
||||||
|
InitialiserGraphique();
|
||||||
|
CreerFenetre(10,10,1000,270);
|
||||||
|
txt(200,135,blablabla,rainbow);
|
||||||
|
Touche();
|
||||||
|
FermerGraphique();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user