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_2/HLIN202/TP/TP7-8/ex6/exo6 | Bin 0 -> 9343 bytes sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 sem_2/HLIN202/TP/TP7-8/ex6/exo6 create mode 100644 sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp (limited to 'sem_2/HLIN202/TP/TP7-8/ex6') diff --git a/sem_2/HLIN202/TP/TP7-8/ex6/exo6 b/sem_2/HLIN202/TP/TP7-8/ex6/exo6 new file mode 100644 index 0000000..56b1f66 Binary files /dev/null and b/sem_2/HLIN202/TP/TP7-8/ex6/exo6 differ diff --git a/sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp b/sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp new file mode 100644 index 0000000..c0c36ef --- /dev/null +++ b/sem_2/HLIN202/TP/TP7-8/ex6/exo6.cpp @@ -0,0 +1,16 @@ +#include + +int occurence ( int T[10], int x) { + int cpt=0; + for ( int i=0; i < 10; i ++) { + cpt += T[i]==x ? 1 : 0; + } + return cpt; +} +int main () { + int tab[10]= {2,3,4,2,3,1,8,2,5,9}; + int x=0; + std::cout<< " Entrez un entier positif, ce programme calcule le nombre d'occurence de cet entier dans le tableau [2 3 4 2 3 1 8 2 5 9]" << std::endl; + std::cin>>x; + std::cout<