/* Fichier Ex2_Str.cpp (utile pour le numéro A du TP2 et pour l'intra) */ #include #include #include using namespace std; // pour consulter l'écran d'exécution void continuer() { char reponse ; cout << "\nAppuyez sur une lettre suivie de Entree " ; cin >> reponse ; } void afficherImpair(string tel) { cout << "Les chiffres impairs dans le numero de telephone " << tel << " sont : "; for(char c = '1' ; c <= '9' ; c += 2) if (tel.find(c) != string::npos) cout << c << " " ; cout << endl; } void afficherCommuns(string tel1, string tel2) { cout << "Les chiffres communs entre " << tel1 << " et " << tel2 << " sont : "; for(char c = '0' ; c <= '9' ; c++) if ( tel1.find(c) != string::npos && tel2.find(c) != string::npos) cout << c << " " ; cout << endl << endl; } int main() { string telUdM = "5143436111", telJean = "4501234567", telJulie = "5146263214"; afficherImpair(telUdM); afficherImpair(telJean); afficherCommuns(telJean, telJulie); continuer(); return 0; } /* Exécution : Les chiffres impairs dans le numero de telephone 5143436111 sont : 1 3 5 Les chiffres impairs dans le numero de telephone 4501234567 sont : 1 3 5 7 Les chiffres communs entre 4501234567 et 5146263214 sont : 1 2 3 4 5 6 Appuyez sur une lettre suivie de Entree f */