Ajout des travaux effectuer
This commit is contained in:
20
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Palindromes.c
Normal file
20
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Palindromes.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int mot;
|
||||
int i;
|
||||
if (argc > 2) {
|
||||
for(i=0;i<;i++){
|
||||
|
||||
if(inverse(argv[])==argv[]){
|
||||
printf("%s est un palindrome");
|
||||
}else{
|
||||
printf("%s n'est pas un palindrome");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
puts("aucun argument !");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
35
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Précognition.c
Normal file
35
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Précognition.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int num = 0;
|
||||
int i, j;
|
||||
double comp;
|
||||
double in;
|
||||
int doublon;
|
||||
char revoir;
|
||||
double* tab = (double*) malloc(sizeof(double));
|
||||
while(revoir != 'q' || revoir != 'Q'){
|
||||
printf("case %d : ", num);
|
||||
scanf("%lf", tab+i);
|
||||
num++;
|
||||
printf("quitter ? ");
|
||||
scanf("%c", &revoir);
|
||||
printf("\n");
|
||||
}
|
||||
for(i=0;i<num;i++){
|
||||
doublon = 0;
|
||||
comp=tab[i];
|
||||
for(j=0;j<num;j++){
|
||||
if((*(tab+i) == *(tab+j) && (tab+i) != (tab+j))){
|
||||
doublon = 1;
|
||||
}
|
||||
}
|
||||
if(doublon == 0){
|
||||
printf("%.2lf, ", comp);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
free(p);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
33
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Singletons.c
Normal file
33
23DEV1.1/TPS1/TP2/18-AllocationDynamique/Singletons.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int num;
|
||||
int i, j;
|
||||
double comp;
|
||||
double in;
|
||||
int doublon;
|
||||
printf("Combien de réel à rentrée ? ");
|
||||
scanf("%d", &num);
|
||||
double* tab = (double*) calloc(num, sizeof(double));
|
||||
for(i=0;i<num;i++){
|
||||
printf("case %d : ", i);
|
||||
scanf("%lf", tab+i);
|
||||
printf("\n");
|
||||
}
|
||||
for(i=0;i<num;i++){
|
||||
doublon = 0;
|
||||
comp=tab[i];
|
||||
for(j=0;j<num;j++){
|
||||
if((*(tab+i) == *(tab+j) && (tab+i) != (tab+j))){
|
||||
doublon = 1;
|
||||
}
|
||||
}
|
||||
if(doublon == 0){
|
||||
printf("%.2lf ", comp);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
free(tab);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/18-AllocationDynamique/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/18-AllocationDynamique/a.out
Executable file
Binary file not shown.
BIN
23DEV1.1/TPS1/TP2/19-Structures/Complexes
Executable file
BIN
23DEV1.1/TPS1/TP2/19-Structures/Complexes
Executable file
Binary file not shown.
54
23DEV1.1/TPS1/TP2/19-Structures/Complexes.c
Normal file
54
23DEV1.1/TPS1/TP2/19-Structures/Complexes.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
struct nbrcomplex{
|
||||
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
typedef struct nbrcomplex complex;
|
||||
|
||||
void afficher(complex z){
|
||||
printf("%f + %fi\n", z.x, z.y);
|
||||
}
|
||||
|
||||
float module(complex z){
|
||||
float res = sqrt(pow(z.x, 2)+pow(z.y, 2));
|
||||
float resrac = pow(res, 0.5);
|
||||
return resrac;
|
||||
}
|
||||
|
||||
complex inverse(complex z){
|
||||
complex a;
|
||||
a.x = z.x/pow(module(z), 2);
|
||||
a.y = z.y/pow(module(z), 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
complex conjugue(complex z){
|
||||
complex b;
|
||||
b.x = z.x;
|
||||
b.y = -z.y;
|
||||
return b;
|
||||
}
|
||||
|
||||
int main(int argc, char const* argv[]){
|
||||
complex z = {3,8};
|
||||
complex a, b, c;
|
||||
|
||||
afficher(z);
|
||||
|
||||
a = z;
|
||||
module(a);
|
||||
printf("|z| = %f\n", a);
|
||||
|
||||
b = conjugue(z);
|
||||
afficher(b);
|
||||
printf("conjugue = %f\n", b);
|
||||
|
||||
c = inverse(z);
|
||||
afficher(c);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
16
23DEV1.1/TPS1/TP2/19-Structures/Numeros.c
Normal file
16
23DEV1.1/TPS1/TP2/19-Structures/Numeros.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
|
||||
struct id_s {
|
||||
int UID;
|
||||
char name;
|
||||
};
|
||||
|
||||
typedef struct id_s id;
|
||||
|
||||
int main(int argc, char const* argv[]){
|
||||
int x = getpwuid();
|
||||
char y = getpwnam();
|
||||
id r = {, };
|
||||
}
|
||||
17
23DEV1.1/TPS1/TP2/19-Structures/Tailles.c
Normal file
17
23DEV1.1/TPS1/TP2/19-Structures/Tailles.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct taille{
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
/*char a;
|
||||
char b;
|
||||
char c;*/
|
||||
};
|
||||
|
||||
typedef struct taille e;
|
||||
|
||||
int main(int argc, char const* argv[]){
|
||||
printf("%d\n",sizeof(e));
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/19-Structures/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/19-Structures/a.out
Executable file
Binary file not shown.
13
23DEV1.1/TPS1/TP2/19-Structures/date.c
Normal file
13
23DEV1.1/TPS1/TP2/19-Structures/date.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
time_t times = time(NULL);
|
||||
struct tm * timeI = localtime(×);
|
||||
printf("Heure locale : %02d:%02d:%02d", timeI->tm_hour, timeI->tm_min, timeI->tm_sec);
|
||||
printf("\n");
|
||||
printf("Date locale : %04d/%02d/%02d",timeI->tm_year+1900,timeI->tm_mon,timeI->tm_mday);
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
42
23DEV1.1/TPS1/TP2/20-Fichier/Challenger.c
Normal file
42
23DEV1.1/TPS1/TP2/20-Fichier/Challenger.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
FILE *f;
|
||||
f=fopen("top10","r");
|
||||
int zone_int[1];
|
||||
int zone_char[3];
|
||||
int i = 0;
|
||||
int j;
|
||||
char name[3];
|
||||
int score;
|
||||
char rep_n;
|
||||
int rep_s;
|
||||
printf("Entrez pseudo : ");
|
||||
while(i<3){
|
||||
name[i] = getchar();
|
||||
i++;
|
||||
}
|
||||
printf("Entrez score : ");
|
||||
scanf("%d", score);
|
||||
if(f != NULL){
|
||||
for(i=0 ; i<10 ; i++){
|
||||
fread(zone_int, 4, 1, f);
|
||||
fread(zone_char, 3, 1, f);
|
||||
if(zone_int[0] <= score){
|
||||
rep_n = zone_int[1];
|
||||
rep_s = zone_char[3];
|
||||
zone_int[0] = score;
|
||||
zone_char[3] = name[3];
|
||||
name[3] = rep_n;
|
||||
score = rep_s;
|
||||
}
|
||||
printf("%09d", zone_int[0]);
|
||||
printf("%c%c%c", zone_char[0], zone_char[1], zone_char[2]);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
17
23DEV1.1/TPS1/TP2/20-Fichier/Copie.c
Normal file
17
23DEV1.1/TPS1/TP2/20-Fichier/Copie.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
FILE *f;
|
||||
FILE *l;
|
||||
f=fopen(argv[1],"r");
|
||||
l=fopen(argv[2],"w");
|
||||
char t[40];
|
||||
fgets(t,40,f);
|
||||
fputs(t,l);
|
||||
fclose(l);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Compteur
Executable file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Compteur
Executable file
Binary file not shown.
26
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Compteur.c
Normal file
26
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Compteur.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
int time = 0;
|
||||
FILE* f;
|
||||
f=fopen("compteur","r");
|
||||
if(f == NULL){
|
||||
f=fopen("compteur","w");
|
||||
fwrite(&time,1,4,f);
|
||||
time = 1;
|
||||
printf("Nombres de fois ouvert : inexistant\n");
|
||||
fclose(f);
|
||||
}
|
||||
else{
|
||||
fread(&time,1,4,f);
|
||||
f=fopen("compteur","w");
|
||||
time++;
|
||||
fwrite(&time,1,4,f);
|
||||
printf("Nombres de fois ouvert : %d\n", time);
|
||||
fclose(f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
27
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Hexadecimal.c
Normal file
27
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Hexadecimal.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
FILE* f;
|
||||
int i;
|
||||
int n = 0;
|
||||
int y;
|
||||
char c[100];
|
||||
f=fopen(argv[1],"r");
|
||||
while(feof(f)==1){
|
||||
for(i=0;i<y;i++){
|
||||
if( c[i] ='\n'){
|
||||
printf("\n");
|
||||
n=n+10;
|
||||
}else{
|
||||
printf("%07d ",n);
|
||||
fread(&c,3,1,f);
|
||||
printf("%c ", c[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
37
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Image.c
Normal file
37
23DEV1.1/TPS1/TP2/20-Fichier/Suite/Image.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
FILE* f;
|
||||
f = fopen("image.bin","r");
|
||||
int i, j;
|
||||
int largeur, hauteur;
|
||||
couleur c;
|
||||
|
||||
fread(&largeur,4,1,f);
|
||||
fread(&hauteur,4,1,f);
|
||||
|
||||
printf("%d\n",largeur);
|
||||
printf("%d\n",hauteur);
|
||||
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10, 10, largeur, hauteur);
|
||||
fseek(f,8*largeur/2*hauteur,SEEK_CUR);
|
||||
for(i=largeur/2;i<largeur;i++){
|
||||
|
||||
fseek(f,8*hauteur/2,SEEK_CUR);
|
||||
|
||||
for(j=hauteur/2;j<hauteur;j++){
|
||||
fread(&c,sizeof(unsigned long),1,f);
|
||||
ChoisirCouleurDessin(c);
|
||||
DessinerPixel(i, j);
|
||||
}
|
||||
|
||||
}
|
||||
Touche();
|
||||
FermerGraphique();
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/a.out
Executable file
Binary file not shown.
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/compteur
Normal file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/compteur
Normal file
Binary file not shown.
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/image.bin
Normal file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/Suite/image.bin
Normal file
Binary file not shown.
1
23DEV1.1/TPS1/TP2/20-Fichier/Takedown.txt
Normal file
1
23DEV1.1/TPS1/TP2/20-Fichier/Takedown.txt
Normal file
@@ -0,0 +1 @@
|
||||
plus que 3 (Répétition, Reproduction, Recherche).
|
||||
BIN
23DEV1.1/TPS1/TP2/20-Fichier/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/a.out
Executable file
Binary file not shown.
21
23DEV1.1/TPS1/TP2/20-Fichier/record.c
Normal file
21
23DEV1.1/TPS1/TP2/20-Fichier/record.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
int s;
|
||||
char b[3];
|
||||
int i;
|
||||
FILE* f;
|
||||
f=fopen("top10","r");
|
||||
printf("|Hall of Fame|\n");
|
||||
for(i=0;i<10;i++){
|
||||
fread(&s,4,1,f);
|
||||
fread(&b,3,1,f);
|
||||
printf("%09d %s\n", s, b);
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
0
23DEV1.1/TPS1/TP2/20-Fichier/roger.gif
Normal file
0
23DEV1.1/TPS1/TP2/20-Fichier/roger.gif
Normal file
0
23DEV1.1/TPS1/TP2/20-Fichier/steve.gif
Normal file
0
23DEV1.1/TPS1/TP2/20-Fichier/steve.gif
Normal file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/top10
Normal file
BIN
23DEV1.1/TPS1/TP2/20-Fichier/top10
Normal file
Binary file not shown.
114
23DEV1.1/TPS1/TP2/21-ListesChainées/Circulation.c
Normal file
114
23DEV1.1/TPS1/TP2/21-ListesChainées/Circulation.c
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
struct maillon
|
||||
{
|
||||
int valeur;
|
||||
struct maillon* suivant;
|
||||
};
|
||||
|
||||
typedef struct maillon maillon;
|
||||
|
||||
unsigned short int estVide(maillon* liste)
|
||||
{
|
||||
return(liste == NULL);
|
||||
}
|
||||
|
||||
maillon* debut(maillon* m, int v)
|
||||
{
|
||||
maillon* result = malloc(sizeof(maillon));
|
||||
result->valeur = v;
|
||||
result->suivant = m;
|
||||
return result;
|
||||
}
|
||||
|
||||
maillon* creerListe()
|
||||
{
|
||||
maillon* m = NULL;
|
||||
unsigned short int val;
|
||||
srand(time(NULL));
|
||||
for(int i = 0; i<10; i++)
|
||||
{
|
||||
val = rand()%(999-111)+111;
|
||||
m = debut(m,val);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
maillon* afficheListe(maillon* liste)
|
||||
{
|
||||
maillon* lecture = liste;
|
||||
while(!estVide(lecture))
|
||||
{
|
||||
printf("%hu\n",lecture->valeur);
|
||||
lecture = lecture->suivant;
|
||||
}
|
||||
}
|
||||
|
||||
maillon* destructListe(maillon* liste)
|
||||
{
|
||||
maillon* lecture = liste;
|
||||
while(lecture != NULL){
|
||||
maillon* temp = lecture;
|
||||
lecture = lecture->suivant;
|
||||
free(temp);
|
||||
}
|
||||
printf("liste effacer\n");
|
||||
}
|
||||
|
||||
maillon* rotationListe(maillon* m)
|
||||
{
|
||||
maillon *lecture=malloc(sizeof(maillon));
|
||||
maillon *temp=lecture;
|
||||
lecture=m;
|
||||
while(lecture->suivant!=NULL){
|
||||
temp=lecture;
|
||||
lecture=lecture->suivant;
|
||||
}
|
||||
temp->suivant=NULL;
|
||||
lecture->suivant=m;
|
||||
return lecture;
|
||||
}
|
||||
|
||||
maillon* rotationListeInverse(maillon* m)
|
||||
{
|
||||
maillon *debut=m;
|
||||
maillon *fin=m;
|
||||
debut=m->suivant;
|
||||
maillon *lecture=m;
|
||||
while(!estVide(lecture->suivant)){
|
||||
lecture=lecture->suivant;
|
||||
}
|
||||
fin->suivant=NULL;
|
||||
lecture->suivant=fin;
|
||||
return debut;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
maillon* l;
|
||||
int rotation, i;
|
||||
for(i = 0 ; i<10; i++){
|
||||
l = creerListe(l);
|
||||
}
|
||||
afficheListe(l);
|
||||
printf("Choisissez une rotation : ");
|
||||
scanf("%d", &rotation);
|
||||
if(rotation == 0){
|
||||
printf("aucune rotation !");
|
||||
}
|
||||
if(rotation > 0){
|
||||
for(i = 0 ; i<rotation ; i++){
|
||||
l=rotationListe(l);
|
||||
}
|
||||
}else if(rotation < 0){
|
||||
for(i = 0 ; i>rotation ; i--){
|
||||
l=rotationListeInverse(l);
|
||||
}
|
||||
}
|
||||
afficheListe(l);
|
||||
destructListe(l);
|
||||
return 0;
|
||||
}
|
||||
84
23DEV1.1/TPS1/TP2/21-ListesChainées/Max.c
Normal file
84
23DEV1.1/TPS1/TP2/21-ListesChainées/Max.c
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
struct maillon
|
||||
{
|
||||
int valeur;
|
||||
struct maillon* suivant;
|
||||
};
|
||||
|
||||
typedef struct maillon maillon;
|
||||
|
||||
unsigned short int estVide(maillon* liste)
|
||||
{
|
||||
return(liste == NULL);
|
||||
}
|
||||
|
||||
maillon* debut(maillon* m, int v)
|
||||
{
|
||||
maillon* result = malloc(sizeof(maillon));
|
||||
result->valeur = v;
|
||||
result->suivant = m;
|
||||
return result;
|
||||
}
|
||||
|
||||
maillon* creerListe()
|
||||
{
|
||||
maillon* m = NULL;
|
||||
unsigned short int val;
|
||||
srand(time(NULL));
|
||||
for(int i = 0; i<10; i++)
|
||||
{
|
||||
val = rand()%(999-111)+111;
|
||||
m = debut(m,val);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
maillon* afficheListe(maillon* liste)
|
||||
{
|
||||
maillon* lecture = liste;
|
||||
while(!estVide(lecture))
|
||||
{
|
||||
printf("%hu\n",lecture->valeur);
|
||||
lecture = lecture->suivant;
|
||||
}
|
||||
}
|
||||
|
||||
maillon* destructListe(maillon* liste)
|
||||
{
|
||||
maillon* lecture = liste;
|
||||
while(lecture != NULL){
|
||||
maillon* temp = lecture;
|
||||
lecture = lecture->suivant;
|
||||
free(temp);
|
||||
}
|
||||
printf("liste effacer\n");
|
||||
}
|
||||
|
||||
maillon* maximumListe(maillon* m)
|
||||
{
|
||||
maillon* lecture = m;
|
||||
unsigned short int max = 0;
|
||||
for(int i = 0 ; i<10 ; i++)
|
||||
{
|
||||
if(lecture->valeur > max){
|
||||
max = lecture->valeur;
|
||||
}
|
||||
lecture=lecture->suivant;
|
||||
}
|
||||
printf("le max est %hu\n", max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
maillon* l;
|
||||
l = creerListe();
|
||||
afficheListe(l);
|
||||
maximumListe(l);
|
||||
destructListe(l);
|
||||
return 0;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/21-ListesChainées/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/21-ListesChainées/a.out
Executable file
Binary file not shown.
76
23DEV1.1/TPS1/TP2/21-ListesChainées/suite/chaines.c
Normal file
76
23DEV1.1/TPS1/TP2/21-ListesChainées/suite/chaines.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
struct chaine_c
|
||||
{
|
||||
char valeur;
|
||||
struct chaine* suivant;
|
||||
};
|
||||
typedef struct chaine_c chaine;
|
||||
maillon* debut(chaine* m, char v)
|
||||
{
|
||||
chaine* result = malloc(sizeof(chaine));
|
||||
result->valeur = v;
|
||||
result->suivant = m;
|
||||
return result;
|
||||
}
|
||||
void ajouter(chaine* l){
|
||||
chaine* m = NULL;
|
||||
char val;
|
||||
srand(time(NULL));
|
||||
for(int i = 0; i<30; i++)
|
||||
{
|
||||
val = rand()%(0x7A-0x61)+0x61;
|
||||
m = debut(m,val);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
chaine* affiche(chaine* liste)
|
||||
{
|
||||
chaine* lecture = liste;
|
||||
while(!estVide(lecture))
|
||||
{
|
||||
printf("%c\n",lecture->valeur);
|
||||
lecture = lecture->suivant;
|
||||
}
|
||||
}
|
||||
chaine* destruct(chaine* liste)
|
||||
{
|
||||
chaine* lecture = liste;
|
||||
while(lecture != NULL){
|
||||
chaine* temp = lecture;
|
||||
lecture = lecture->suivant;
|
||||
free(temp);
|
||||
}
|
||||
printf("liste effacer\n");
|
||||
}
|
||||
chaine* transformListe(char f[30]){
|
||||
int i = 0;
|
||||
while(f[i]!='\0'){
|
||||
val = rand()%(0x7A-0x61)+0x61;
|
||||
m = debut(m,val);
|
||||
}
|
||||
}
|
||||
char* transformChaine(chaine* liste){
|
||||
chaine* lecture = liste;
|
||||
char new[30];
|
||||
int i = 0;
|
||||
while(lecture!=NULL){
|
||||
chaine* temps = lecture;
|
||||
lecture=lecture->suivant;
|
||||
temps = new[i];
|
||||
i++;
|
||||
}
|
||||
return new;
|
||||
}
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
chaine* l;
|
||||
char l[6]={"Tasty"};
|
||||
l = creerListe();
|
||||
affiche(l)
|
||||
destruct(l);
|
||||
return 0;
|
||||
}
|
||||
20
23DEV1.1/TPS1/TP2/22-Recursive/Curiosity.c
Normal file
20
23DEV1.1/TPS1/TP2/22-Recursive/Curiosity.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int f(int n) {
|
||||
if (n>100)
|
||||
return n-10;
|
||||
else
|
||||
return f(f(n+11));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
srand(time(NULL));
|
||||
int final;
|
||||
int alea = rand()%1000+1000;
|
||||
final = f(alea);
|
||||
printf("%d", final);
|
||||
return 0;
|
||||
}
|
||||
51
23DEV1.1/TPS1/TP2/22-Recursive/Fibonacci.c
Normal file
51
23DEV1.1/TPS1/TP2/22-Recursive/Fibonacci.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int Fibonacci(int n)
|
||||
{
|
||||
if(n==0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(n==1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(n>=2)
|
||||
{
|
||||
n = Fibonacci(n-2)+Fibonacci(n-1);
|
||||
return n;
|
||||
}
|
||||
Fibonacci(n+1);
|
||||
}
|
||||
int afficheFibo(int m)
|
||||
{
|
||||
if(m!=0)
|
||||
{
|
||||
if(m==1)
|
||||
{
|
||||
printf("u%d = %d",m,Fibonacci(1));
|
||||
}
|
||||
if(m>=2)
|
||||
{
|
||||
printf("u%d = %d",m,Fibonacci(m));
|
||||
}
|
||||
afficheFibo(m-1);
|
||||
}
|
||||
if(m==0)
|
||||
{
|
||||
printf("u%d = %d\n",m,Fibonacci(0));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
int m = 15;
|
||||
afficheFibo(m);
|
||||
//int n;
|
||||
//printf("choisissez un nombre : ");
|
||||
//scanf("%d",&n);
|
||||
//printf("u%d = %d",n,Fibonacci(n));
|
||||
return 0;
|
||||
}
|
||||
23
23DEV1.1/TPS1/TP2/22-Recursive/Tableau.c
Normal file
23
23DEV1.1/TPS1/TP2/22-Recursive/Tableau.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
void tableau(double tab[5], int d)
|
||||
{
|
||||
int num = d;
|
||||
printf("%lf", tab[num]);
|
||||
if(num<4){
|
||||
printf(", ");
|
||||
tableau(tab, num+1);
|
||||
}else{
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
double tab[5] = {1.25, 47.80, 77.01, 54.23, 895.14};
|
||||
tableau(tab, 0);
|
||||
return 0;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/22-Recursive/Triangle
Executable file
BIN
23DEV1.1/TPS1/TP2/22-Recursive/Triangle
Executable file
Binary file not shown.
28
23DEV1.1/TPS1/TP2/22-Recursive/Triangle.c
Normal file
28
23DEV1.1/TPS1/TP2/22-Recursive/Triangle.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
|
||||
void triangle(int x1, int y1, int x2, int y2,int x3, int y3, int n){
|
||||
if(n == 0){
|
||||
DessinerSegment(x1, y1, x2, y2);
|
||||
DessinerSegment(x2, y2, x3, y3);
|
||||
DessinerSegment(x3, y3, x1, y1);
|
||||
}else{
|
||||
triangle(x1, y1, (x2+x1)/2, y2, (x1+x3)/2, (y2+y3)/2, n-1);
|
||||
triangle((x1+x2)/2, y1, x2, y2, (x2+x3)/2, (y2+y3)/2, n-1);
|
||||
triangle((x1+x3)/2, (y1+y3)/2, (x2+x3)/2, (y2+y3)/2, x3, y3, n-1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int n = 0;
|
||||
printf("Entrez un entier positif : ");
|
||||
scanf("%d", &n);
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,1000,800);
|
||||
triangle(10, 790, 990, 790, 500, 10, n);
|
||||
Touche();
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/22-Recursive/a.out
Executable file
BIN
23DEV1.1/TPS1/TP2/22-Recursive/a.out
Executable file
Binary file not shown.
17
23DEV1.1/TPS1/TP2/22-Recursive/phrases.c
Normal file
17
23DEV1.1/TPS1/TP2/22-Recursive/phrases.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void exemple(unsigned n) {
|
||||
if (n != 0) {
|
||||
putchar('>');//à la fin
|
||||
exemple(n-1);
|
||||
putchar('<');//au début
|
||||
} else
|
||||
putchar('O');
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
exemple(100);
|
||||
return 0;
|
||||
}
|
||||
59
23DEV1.1/TPS1/TP2/23-Piles/Chainee.c
Normal file
59
23DEV1.1/TPS1/TP2/23-Piles/Chainee.c
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct maillon_s{
|
||||
char valeur;
|
||||
struct maillon_s* suivant;
|
||||
};
|
||||
|
||||
typedef struct maillon_s maillon;
|
||||
|
||||
void push(Pile* pile, int element) {
|
||||
Maillon* nouveauMaillon = (Maillon*)malloc(sizeof(Maillon));
|
||||
if (nouveauMaillon == NULL) {
|
||||
|
||||
fprintf(stderr, "Erreur d'allocation mémoire.\n");
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
}
|
||||
nouveauMaillon->donnee = element;
|
||||
nouveauMaillon->suivant = pile->sommet;
|
||||
pile->sommet = nouveauMaillon;
|
||||
}
|
||||
|
||||
int pop(Pile* pile) {
|
||||
if (!pile_empty(pile)) {
|
||||
Maillon* maillonPop = pile->sommet;
|
||||
int donneePop = maillonPop->donnee;
|
||||
pile->sommet = maillonPop->suivant;
|
||||
free(maillonPop);
|
||||
return donneePop;
|
||||
} else {
|
||||
fprintf(stderr, "La pile est vide.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int empty(const Pile* pile) {
|
||||
return (pile->sommet == NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
void push(pile* p, char new){
|
||||
maillon* m = (maillon) malloc(sizeof(maillon));
|
||||
m->valeur = nouveaux;
|
||||
m->suivant = *p;
|
||||
*p = m;
|
||||
}
|
||||
|
||||
char pop(pile* p){
|
||||
maillon* m = (*p)-> valeur;
|
||||
pile* tp = *p;
|
||||
|
||||
}
|
||||
|
||||
int empty(pile* p){
|
||||
return p == NULL;
|
||||
}
|
||||
*/
|
||||
78
23DEV1.1/TPS1/TP2/24-Files/Chainee.c
Normal file
78
23DEV1.1/TPS1/TP2/24-Files/Chainee.c
Normal file
@@ -0,0 +1,78 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct maillon_s{
|
||||
char valeur;
|
||||
struct maillon_s* suivant;
|
||||
};
|
||||
|
||||
typedef struct maillon_s maillon;
|
||||
|
||||
struct file{
|
||||
maillon* premier;
|
||||
maillon* dernier;
|
||||
};
|
||||
|
||||
/*void clear(file* f){
|
||||
|
||||
}
|
||||
|
||||
char first(file* f){
|
||||
|
||||
}*/
|
||||
|
||||
void enqueue(file* f, char new){
|
||||
maillon* m = (maillon) malloc(sizeof(maillon));
|
||||
m->valeur = nouveaux;
|
||||
m->suivant=NULL;
|
||||
if(f->dernier!=NULL){
|
||||
f->dernier->suivant = m;
|
||||
}else{
|
||||
f->permier = m;
|
||||
}
|
||||
f->dernier = m;
|
||||
}
|
||||
|
||||
char dequeue(file* f){
|
||||
maillon m = *(f->premier);
|
||||
free(f->premier);
|
||||
f->premier = m.suivant;
|
||||
if(f->premier == NULL){
|
||||
f->dernier = NULL;
|
||||
}
|
||||
return m.valeur;
|
||||
}
|
||||
|
||||
int empty(const file* f){
|
||||
return f->premier == NULL;
|
||||
}
|
||||
|
||||
int main(void){
|
||||
int n;
|
||||
char ch[2];
|
||||
struct file* f;
|
||||
char val;
|
||||
n = 0;
|
||||
printf("Le File attends vos ordre\n");
|
||||
while(n < 2){
|
||||
ch[n] = getchar();
|
||||
n++;
|
||||
}
|
||||
while(ch[0] != 'q'){
|
||||
n = 0;
|
||||
if(ch[0] == '+'){
|
||||
val = ch[1];
|
||||
enqueue(f, val);
|
||||
printf("Le caractère %c a ete ajoute\n", val);
|
||||
}else if(ch[0] == '-'){
|
||||
val = dequeue(f);
|
||||
printf("Le caractère %c a ete supprime\n", val);
|
||||
}
|
||||
printf(">");
|
||||
while(n < 2){
|
||||
ch[n] = getchar();
|
||||
n++;
|
||||
}
|
||||
}
|
||||
printf("Au revoir");
|
||||
}
|
||||
31
23DEV1.1/TPS1/TP2/controle/CM2_2022/2Representation.c
Normal file
31
23DEV1.1/TPS1/TP2/controle/CM2_2022/2Representation.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void afficherImage(const char *nomFichier) {
|
||||
FILE *fichier = fopen(nomFichier, "rb");
|
||||
int couleur;
|
||||
|
||||
|
||||
if (fichier == NULL) {
|
||||
perror("Erreur lors de l'ouverture du fichier");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (fread(&couleur, 1, 1, fichier) == 1) {
|
||||
if (couleur == 0) {
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("\33[48;5;%dm \33[m", couleur);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fichier);
|
||||
}
|
||||
|
||||
int main() {
|
||||
const char *nomFichier = "image";
|
||||
|
||||
afficherImage(nomFichier);
|
||||
|
||||
return 0;
|
||||
}
|
||||
53
23DEV1.1/TPS1/TP2/controle/CM2_2022/2Reproduction.c
Normal file
53
23DEV1.1/TPS1/TP2/controle/CM2_2022/2Reproduction.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int compare_fichiers(const char *nom_fichier1, const char *nom_fichier2) {
|
||||
FILE *fichier1 = fopen(nom_fichier1, "rb");
|
||||
FILE *fichier2 = fopen(nom_fichier2, "rb");
|
||||
|
||||
if (fichier1 == NULL || fichier2 == NULL) {
|
||||
perror("Erreur lors de l'ouverture des fichiers");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int caractere1, caractere2;
|
||||
|
||||
while (1) {
|
||||
caractere1 = fgetc(fichier1);
|
||||
caractere2 = fgetc(fichier2);
|
||||
|
||||
if (caractere1 != caractere2) {
|
||||
fclose(fichier1);
|
||||
fclose(fichier2);
|
||||
return 0; /*Les fichiers ne sont pas identiques*/
|
||||
}
|
||||
|
||||
if (caractere1 == EOF) {
|
||||
break; /*Fin des fichiers*/
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fichier1);
|
||||
fclose(fichier2);
|
||||
|
||||
return 1; /*Les fichiers sont identiques*/
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: %s <fichier1> <fichier2>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int resultat = compare_fichiers(argv[1], argv[2]);
|
||||
|
||||
if (resultat == 1) {
|
||||
printf("Fichiers identiques !\n");
|
||||
} else if (resultat == 0) {
|
||||
printf("Fichiers non identiques !\n");
|
||||
} else {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
25
23DEV1.1/TPS1/TP2/controle/CM2_2022/3Ralenti.c
Normal file
25
23DEV1.1/TPS1/TP2/controle/CM2_2022/3Ralenti.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
const char* mot = "ERREUR";
|
||||
struct timespec attente;
|
||||
int i;
|
||||
|
||||
attente.tv_sec = 0;
|
||||
attente.tv_nsec = 500000000;
|
||||
|
||||
for (i = 0; i < strlen(mot); i++) {
|
||||
putchar(mot[i]);
|
||||
fflush(stdout);
|
||||
if (nanosleep(&attente, NULL) == -1) {
|
||||
perror("nanosleep");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
return 0;
|
||||
}
|
||||
27
23DEV1.1/TPS1/TP2/controle/CM2_2022/3Rapidite.c
Normal file
27
23DEV1.1/TPS1/TP2/controle/CM2_2022/3Rapidite.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int main() {
|
||||
struct timeval start, end;
|
||||
double result;
|
||||
|
||||
/*Enregistrez le temps de début*/
|
||||
gettimeofday(&start, NULL);
|
||||
|
||||
/* Effectuez le calcul un million de fois */
|
||||
int i;
|
||||
for (i = 0; i < 1000000; ++i) {
|
||||
result = sqrt(2.0);
|
||||
}
|
||||
|
||||
/* Enregistrez le temps de fin */
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
/* Calculez le temps écoulé en microsecondes */
|
||||
long elapsed_time = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
|
||||
|
||||
printf("%ldμs\n", elapsed_time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
35
23DEV1.1/TPS1/TP2/controle/CM2_2022/Makefile
Normal file
35
23DEV1.1/TPS1/TP2/controle/CM2_2022/Makefile
Normal file
@@ -0,0 +1,35 @@
|
||||
#BUT FINAL
|
||||
|
||||
all : Repetition exo3
|
||||
|
||||
#Variables
|
||||
|
||||
OFILES = main.o \
|
||||
Repetition.o
|
||||
|
||||
CC = gcc
|
||||
|
||||
CFLAGS = -Wall -ansi -pedantic
|
||||
|
||||
#Dépendances
|
||||
|
||||
main.o: main.c Repetition.h
|
||||
|
||||
Repetition.o: Repetition.c Repetition.h
|
||||
|
||||
#Exec
|
||||
|
||||
Repetition: $(OFILES)
|
||||
$(CC) $(CFLAGS) -o Repetition $(OFILES) && rm -f *.o && echo "Utilisation : ./Repetition"
|
||||
|
||||
exo3 : 3Ralenti.c
|
||||
$(CC) $(CFLAGS) -std=gnu99 -o exo3 3Ralenti.c && echo "Utilisation : ./exo3"
|
||||
|
||||
#Nettoyage
|
||||
|
||||
clean:
|
||||
rm -f Repetition && rm -f exo3
|
||||
|
||||
#But factice
|
||||
|
||||
.PHONY : but clean
|
||||
12
23DEV1.1/TPS1/TP2/controle/CM2_2022/Repetition.c
Normal file
12
23DEV1.1/TPS1/TP2/controle/CM2_2022/Repetition.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdbool.h>
|
||||
#include "Repetition.h"
|
||||
|
||||
bool sont_identiques(const long tableau[], int taille) {
|
||||
int i;
|
||||
for (i = 1; i < taille; ++i) {
|
||||
if (tableau[i] != tableau[0]) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
8
23DEV1.1/TPS1/TP2/controle/CM2_2022/Repetition.h
Normal file
8
23DEV1.1/TPS1/TP2/controle/CM2_2022/Repetition.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef REPETITION_H
|
||||
#define REPETITION_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool sont_identiques(const long tableau[], int taille);
|
||||
|
||||
#endif
|
||||
BIN
23DEV1.1/TPS1/TP2/controle/CM2_2022/image
Normal file
BIN
23DEV1.1/TPS1/TP2/controle/CM2_2022/image
Normal file
Binary file not shown.
38
23DEV1.1/TPS1/TP2/controle/CM2_2022/main.c
Normal file
38
23DEV1.1/TPS1/TP2/controle/CM2_2022/main.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "Repetition.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int taille = argc - 1;
|
||||
int i;
|
||||
long *tableau = malloc(taille * sizeof(long));
|
||||
bool resultat = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s <entiers...>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!tableau) {
|
||||
perror("Erreur d'allocation de mémoire");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
tableau[i - 1] = strtol(argv[i], NULL, 10);
|
||||
}
|
||||
|
||||
resultat = sont_identiques(tableau, taille);
|
||||
|
||||
if (resultat) {
|
||||
printf("valeurs identiques\n");
|
||||
} else {
|
||||
printf("valeurs non identiques\n");
|
||||
}
|
||||
|
||||
free(tableau);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
BIN
23DEV1.1/TPS1/TP2/controle/CM2_2022/test
Executable file
BIN
23DEV1.1/TPS1/TP2/controle/CM2_2022/test
Executable file
Binary file not shown.
18
23DEV1.1/TPS1/TP2/controle/Ralenti.c
Normal file
18
23DEV1.1/TPS1/TP2/controle/Ralenti.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct timespec tim, tim2;
|
||||
tim.tv_sec = 1;
|
||||
tim.tv_nsec = 2;
|
||||
|
||||
if(nanosleep(&tim , &tim2) < 0 )
|
||||
{
|
||||
printf("Nano sleep system call failed \n");
|
||||
return -1;
|
||||
}
|
||||
printf("ERREUR\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
21
23DEV1.1/TPS1/TP2/controle/Rapidite.c
Normal file
21
23DEV1.1/TPS1/TP2/controle/Rapidite.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct timeval start, end;
|
||||
double result;
|
||||
int i;
|
||||
|
||||
gettimeofday(&start,NULL);
|
||||
for(i = 0 ; i<1000000 ; i++){
|
||||
result = sqrt(2.0);
|
||||
}
|
||||
|
||||
gettimeofday(&end,NULL);
|
||||
long elapsed_time = (end.tv_sec-start.tv_sec)*1000000+(end.tv_usec-start.tv_usec);
|
||||
printf("%ldµs\n",elapsed_time);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user