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 44 45
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
unsigned int d;
vector <unsigned int> t; // Vecteur qui contiendra le nombre à entrer
vector <unsigned int> z; // Vecteur qui contiendra "t" sans les doublons.
cout << "Entrez un nombre : ";
cin >> d;
while (d!=0)
{
t.push_back(d%10);
d /= 10;
}
for (unsigned int i=0; i<t.size(); i++){
for (unsigned int k=0; k<z.size(); k++)
if (z[k] == t[i])
goto suite;
cout << t [i] << " : " << i << " ";
for (unsigned int j=i+1; j<t.size(); j++)
if (t[j] == t[i])
cout << j << " ";
z.push_back(t[i]);
cout << endl;
suite:
;
}
} |