This commit is contained in:
moogin 2024-10-14 13:54:43 +02:00
parent b3480330b6
commit 1ddc2455c8
6 changed files with 221 additions and 6 deletions

52
DEV1.1/adress.c Normal file
View File

@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*#1)
int main(void){
float a;
double b;
long double c;
char d;
short int e;
int f;
unsigned long int g;
printf("%p\n", a);
printf("%p\n", b);
printf("%p\n", c);
printf("%p\n", d);
printf("%p\n", e);
printf("%p\n", f);
printf("%p\n", g);
}*/
/*#2)
int main(void){
char min, maj;
char *p = NULL;
for(min = 'a', maj = 'A'; maj <= 'Z'; min++, maj++) {
p = (p == &min) ? &maj : &min;
putchar(*p);
}
putchar('\n');
return EXIT_SUCCESS;
}*/
int main(void){
if(time(NULL)%2){
int x = 59;
p = &x;
} else {
int y = 31;
p = &y;
}
/* fragment inactif
printf("x=%d\n", x);
printf("y=%d\n", y);
*/
printf("%d\n", *p);
return EXIT_SUCCESS;
}

View File

@ -29,16 +29,23 @@
}*/ }*/
int main(void){ int main(void){
char triangle; char choix;
int hauteur = 0; int hauteur = 0;
int i; int i;
int n = 0; int n = 0;
int etoile; int etoile;
printf("entrer votre choix: "); int coter;
scanf("%c", &triangle); int a;
int ecart;
if(triangle == 't'){
printf("entrer votre choix: ");
scanf("%c", &choix);
if(choix == 't'){
printf("entrer la hauteur du sapin: "); printf("entrer la hauteur du sapin: ");
scanf("%d", &hauteur); scanf("%d", &hauteur);
@ -48,9 +55,37 @@ int main(void){
printf("*"); printf("*");
} }
n += 2; n += 1;
printf("\n"); printf("\n");
} }
}else if(choix == 'c'){
printf("entrer la longueur du carre : ");
scanf("%d", &coter);
for(a = 0; a < coter; a++){
printf("*");
}
printf("\n");
for(a = 0; a < (coter - 2); a++){
printf("*");
for(ecart = 0; ecart < (coter - 2); ecart++){
printf(" ");
}
printf("*");
printf("\n");
} }
for (a = 0; a < coter; a++){
printf("*");
}
printf("\n");
}else if(choix == 'q'){
return EXIT_SUCCESS;
}else{
printf("caractère non reconues\n");
}
} }

16
DEV1.1/debogueur.c Executable file
View File

@ -0,0 +1,16 @@
#include <stdlib.h>
#include <stdio.h>
int somme(int n, int m) {
return n+m;
}
int main(void) {
int valeur;
int* p = NULL;
printf("Entrez un entier : ");
scanf("%d", p);
printf("Le double vaut %d\n", somme(*p, *p));
return EXIT_SUCCESS;
}

46
DEV1.1/fonction.c Normal file
View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
int triangle(int hauteur, int n =1, int i, int etoile){
for (i = 0; i < hauteur; i++){
for(etoile = 0; etoile < n; etoile++){
printf("*");
}
n += 2;
printf("\n");
}
}
int carre(int coter = 0, int ecart, int a, int etoile){
for (a = 0, a < coter, a++){
pritnf("*");
}
for (a = 0, a < (coter - 2), a++){
printf("*");
for(ecart = 0, ecart < (coter - 2), ecart++){
pritnf(" ");
}
printf("*");
}
for (a = 0, a < coter, a++){
pritnf("*");
}
}
int menu(char choix){
pritnf("triangle : t\ncarre : c\nquitter : q\nenter votre choix : ");
scanf("%c", &choix);
printf("\n");
}
int main(void){
}

View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int t1 [2] [5] ={{1,2,3,4,5}, {1,2,3,4,5}};
int t2 [3] [5] ={{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,14,15}};
int t3 [5] [5] ={{0,0,0,0,0}, {1,0,0,0,0}, {1,2,0,0,0}, {1,2,3,0,0}, {1,2,3,4,0}};
int i;
for(i = 0; i < 10; i++){
printf(" | ");
printf("%d", t1[i]);
}
printf("\n");
for(i = 0; i < 15; i++){
printf(" | ");
printf("%d", t2[i]);
}
printf("\n");
for(i = 0; i < 25; i++){
printf(" | ");
printf("%d", t3[i]);
}
printf("\n");
}

38
DEV1.1/tableaux.c Normal file
View File

@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void){
int tableau[10];
int i;
int x;
int a;
int plus_grand;
srand(time(NULL));
for (i = 0; i < 10; i++){
tableau[i] = (rand() &101 ) -50 ;
}
for (x = 0; x < 10; x++){
printf(" | ");
printf("%d", tableau[x]);
}
printf("\n");
for (a = 0; a < 10; a++){
if (tableau[a] > plus_grand){
plus_grand = tableau[a];
}
}
printf("le plus grand est : ");
printf("%d", plus_grand);
printf("\n");
return EXIT_SUCCESS;
}