fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. bool findAllDigits(istream & i){
  7. vector<int> digits(0);
  8. int tmp; char c; bool found;
  9.  
  10. while(i >> c){//read one char
  11. if(isdigit(c)){//check if it is a number
  12. tmp = c - '0';//convert char to int
  13. found = false;
  14. for(size_t i = 0; i < digits.size(); ++i){
  15. if(tmp == digits[i]){
  16. found = true; break;
  17. }
  18. }
  19. if(!found){//if this number wasn't in the vector yet
  20. digits.push_back(tmp);
  21. }
  22. }
  23. }
  24. return digits.size() == 10;//return true if all the digits are in the stream
  25. }
  26.  
  27.  
  28. int main() {
  29. cout << (findAllDigits(cin)?"FOUND":"NOT FOUND") << endl;
  30. return 0;
  31. }
Success #stdin #stdout 0s 3472KB
stdin
123, 8, 670, 4835134, 50243,9
stdout
FOUND