Commit 5c120219 authored by Anthony Bocquet's avatar Anthony Bocquet
Browse files

initial commit

parent 3a2200f7
Pipeline #30289 canceled with stages
{
"files.associations": {
"tp3.h": "c"
}
}
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
typedef struct Element Element;
struct Element{
int nombre;
Element *suivant;
};
typedef struct Liste Liste;
struct Liste{
Element *premier;
};
int main(int argc, char const *argv[])
{
return 0;
}
diff(Liste* a, Liste* b, Liste* c){
if(a->premier->nombre == b->premier->nombre){
Liste* succa = malloc(sizeof(*succa));
succa->premier = a->premier->suivant;
Liste* succb = malloc(sizeof(*succb));
succb->premier = b->premier->suivant;
diff(succa, succb, c);
}
if(a->premier == NULL){
}
}
\ No newline at end of file
File added
#include <stdio.h>
#include <stdlib.h>
struct Structmonome{
int coef;
int deg;
struct Structmonome* suivant;
};
typedef struct Structmonome* Polynome;
Polynome polynomeconstructeur(int c, int d, Polynome P);
int degre(Polynome p);
void afficherPolynome(Polynome p);
int main(int argc, char const *argv[])
{
return 0;
}
Polynome polynomeconstructeur(int c, int d, Polynome p){
struct Structmonome *Monome = malloc(sizeof(struct Structmonome));
if(Monome == NULL){
exit(EXIT_FAILURE);
}
Monome->coef = c;
Monome->deg = d;
Monome->suivant = p;
p = Monome;
return p;
};
int degre(Polynome p){
int deg = -1;
Polynome pm = p;
while(pm != NULL){
if(pm->deg > deg) deg = pm->deg;
pm = pm->suivant;
}
return deg;
}
void afficherPolynome(Polynome p){
Polynome pm = p;
while(pm != NULL){
if(pm->coef != 0){
if(pm->deg == 0){
printf("%d", pm->coef);
}
else if(pm->deg == 1) {
printf("%d x", pm->coef);
}
else{
printf("%d x^%d", pm->coef, pm->deg);
}
}
if(pm->suivant->coef > 0) printf("+");
pm = pm->suivant;
}
}
\ No newline at end of file
File added
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 20
typedef struct pile {
int tete;
int pile[MAX_SIZE];
} pile_t;
pile_t* creer_pile();
int pile_vide(pile_t* pile);
void empiler(pile_t* pile, int val);
int depiler(pile_t* pile);
int main(int argc, char const *argv[])
{
pile_t* pile = creer_pile();
printf("%d\n", pile->tete);
printf("%d\n", pile_vide(pile));
empiler(pile, 7);
empiler(pile, 2);
printf("%d\n", depiler(pile));
printf("%d\n", pile_vide(pile));
return 0;
}
/* -------------------------------------------- */
pile_t* creer_pile(){
pile_t* pile = malloc(sizeof(pile_t));
pile->tete = 0;
return pile;
};
int pile_vide(pile_t* pile){
if(pile->tete == 0) return 1;
return 0;
};
void empiler(pile_t* pile, int val){
pile->pile[pile->tete] = val;
pile->tete++;
};
int depiler(pile_t* pile){
pile->tete--;
int temp = pile->pile[pile->tete];
pile->pile[pile->tete] = 0;
return temp;
};
\ No newline at end of file
File added
#include <stdio.h>
#include <stdlib.h>
#define MAX_F 10
typedef struct file{
int tete;
int queue;
int tab[MAX_F];
} file_t;
file_t* creer_file();
int file_vide(file_t* file);
void enfiler(file_t* file, int val);
int main(int argc, char const *argv[])
{
file_t* file = creer_file();
printf("%d, %d\n", file->queue, file->tete);
enfiler(file, 7);
printf("%d, %d\n", file->queue, file->tete);
printf("%d, %d\n", file->tab[file->queue], file->tab[file->tete]);
return 0;
}
file_t* creer_file(){
file_t* file = malloc(sizeof(file_t));
file->tete = 0;
file->queue = 0;
};
int file_vide(file_t* file){
if(file->tete == file->queue) return 1;
return 0;
};
void enfiler(file_t* file, int val){
file->tab[file->queue] = val;
if(file->queue == MAX_F - 1){
file->queue = 0;
}else{
file->queue++;
}
}
\ No newline at end of file
#include <stdio.h>
// Programme 1
void main (){
int A=20 , B=5;
int C=!--A /++! B; //error: expression is not assignable
printf ("A=%d B=%d c=%d \n", A,B,C);
}
// Programme 2
// int main (){
// int A=20 , B=5, C= -10, D=2;
// printf ("%d \n", A&&B ||!0&& C ++&&! D++); // 1
// printf ("c=%d d=%d \n", C, D); // c = -10 | d = 2
// }
// Programme 3
// int main (){
// int p[4]={1 , -2 ,3 ,4};
// int *q=p;
// printf("%d",*q);
// printf ("c=%d\n", *++q**q ++); // c = 4
// printf ("c=%d \n" ,*q); // c = 3
// }
// Programme 4
// int main (){
// int p [4]={1 , -2 ,3 ,4};
// int *q=p;
// int d=*q&*q ++|* q++;
// printf ("d=%d\n", d); // d = -1
// printf ("q=%d \n" ,*q); // q = 3
// }
// Programme 5
// int main (){
// int a=-8,b =3;
// int c= ++a&&--b ? b-- :a ++;
// printf ("a=%d b=%d c=%d\n",a,b,c); // a = -7 | b = 1 | c = 2
// }
// Programme 6
// int main (){
// int a=-8,b =3;
// a > >=2^b; // error: expected expression
// printf ("a=%d\n",a); // a=-3
// }
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a,b = 0;
printf("Entrez le 1er nombre : ");
scanf("%i", &a);
printf("\nEntrez le 2eme nombre : ");
scanf("%i", &b);
printf("\n%i + %i = %i\n", a, b, a+b);
return 0;
}
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a, b, temp = 0;
printf("a = ?");
scanf("%d", &a);
printf("\nb = ?");
scanf("%d", &b);
// inversion
temp = a;
a = b;
b = temp;
printf("\na = %d , b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int main(int argc, char const *argv[])
{
float x, y = 0;
printf("Entrez un nombre : ");
scanf("%f", &y);
printf("\nEntrez un pourcentage : ");
scanf("%f", &x);
printf("\n%f %% de %f = %f\n", x, y, (x*y)/100);
return 0;
}
#include <stdio.h>
int main(int argc, char const *argv[])
{
float f, c;
printf("Entrez une température en Fahrenheit : ");
scanf("%f", &f);
c = (5/9)*(f - 32);
printf("\n %f Fahrenheit = %f Celsius\n", f, (f-32)*5/9);
return 0;
}
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a = 0;
printf("Entrez un entier : ");
scanf("%d", &a);
printf("\n%d en hexadecimal vaut : %x\n", a, a);
printf("\n%d en octal vaut : %o\n", a, a);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment