1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #include <iostream>
#define NBLIGNES 3
struct Tab
{
long a, b;
};
using namespace std;
inline bool operator==(Tab const &tabA, Tab const &tabB);
int main()
{
Tab tableau[NBLIGNES];
// remplissage du tableau :
tableau[0].a = 2;
tableau[0].b = 25;
tableau[1].a = 3;
tableau[1].b = 35;
tableau[2].a = 3;
tableau[2].b = 35;
// comparaison des éléments du tableau :
for (unsigned long i = 0 ; i < NBLIGNES-1 ; i++)
{
cout << i << " et " << i+1 << " sont ";
if (tableau[i] == tableau[i+1]) cout << "identiques" << endl;
else cout << "differents" << endl;
}
system("pause");
return 0;
}
inline bool operator==(Tab const &tabA, Tab const &tabB)
{
return tabA.a == tabB.a && tabA.b == tabB.b;
} |