From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp (limited to 'sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp') diff --git a/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp b/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp new file mode 100644 index 0000000..18d30ab --- /dev/null +++ b/sem_3/algo/tp1-done/PROG_TP1/mainTP1.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include +#include "outilsTab.h" + +using namespace std; + + +int main(int argc, char ** argv) +{ + int* Tab; + struct triplet res; + int sm, taille, q; + clock_t t1, t2; + + srand(time(NULL)); + printf("Numero de la question traitee (1/2/3/4) ? "); + scanf("%d",&q); + switch (q){ + case 1 : + taille=1000; + Tab=genTab(taille); + t1=clock(); sm=ssTabSomMax1(Tab,taille); t2=clock(); + cout << "\n Somme Max1 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax2(Tab,taille); t2=clock(); + cout << "\n Somme Max2 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax3(Tab,taille); t2=clock(); + cout << "\n Somme Max3 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + t1=clock(); sm=ssTabSomMax4(Tab,taille); t2=clock(); + cout << "\n Somme Max4 : " << sm << " tps : " << (double) (t2-t1)/ (double) CLOCKS_PER_SEC << endl; + + break; + case 2 : + fichierTemps("sm1.dat", 1000, 100, ssTabSomMax1); + fichierTemps("sm2.dat", 1000, 100, ssTabSomMax2); + fichierTemps("sm3.dat", 1000, 100, ssTabSomMax3); + fichierTemps("sm4.dat", 1000, 100, ssTabSomMax4); + system("gnuplot trace1.gnu"); + fichierTemps("sm2.dat", 20000, 1000, ssTabSomMax2); + fichierTemps("sm3.dat", 20000, 1000, ssTabSomMax3); + fichierTemps("sm4.dat", 20000, 1000, ssTabSomMax4); + system("gnuplot trace2.gnu"); + fichierTemps("sm3.dat", 1000000, 100000, ssTabSomMax3); + fichierTemps("sm4.dat", 10000000, 1000000, ssTabSomMax4); + system("gnuplot trace3.gnu"); + break; + case 3 : + Tab=genTab(20); + afficheTab(Tab,20); + res=indSsTabSomMax(Tab,20); + cout << "\n somme Max : " << res.somMax << "\n debut souTab : " << res.deb << "\n fin SouTab : " << res.fin << endl; + break; + case 4 : + Tab=genTab(20); + afficheTab(Tab,20); + rangerElemNeg(Tab,20); + afficheTab(Tab,20); + break; + } + return 0; +} + -- cgit v1.2.3