TP0: added part 3

This commit is contained in:
Yohan Boujon 2021-12-18 14:56:50 +01:00
parent c9de899b5b
commit 9d6885a3b9
2 changed files with 80 additions and 0 deletions

37
tp0/p3/main.cpp Executable file
View file

@ -0,0 +1,37 @@
#include <iostream>
#define MAX 10
using namespace std;
float calculMoyenne (float dsqdsq[]);
int calculMoyenne (int tab[]);
int main()
{
int tabEntier[MAX+1]={10,12,20,18,9,10,12,20,18,15};
float tabFlottant[MAX+1]={1.0,2.3,5.7,2.1,7.3,2.4,5.6,7.1,5.0,3.0};
int moyenneEntier = calculMoyenne(tabEntier);
float moyenneFlottant = calculMoyenne(tabFlottant);
cout << "Moyenne Entier :" << moyenneEntier << endl;
cout << "Moyenne Flottant :" << moyenneFlottant << endl;
return 0;
}
float calculMoyenne (float tab[])
{
float moyenne(0);
for(int i(0); i<MAX ; i++)
{
moyenne = moyenne + tab[i];
};
return moyenne/10;
}
int calculMoyenne (int tab[])
{
int moyenne(0);
for(int i(0); i<MAX; i++)
{
moyenne = moyenne + tab[i];
}
return moyenne/MAX;
}

43
tp0/p3/p3.cbp Executable file
View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="p3" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/p3" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/p3" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>