fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int C;
  8. cin>>C;
  9. while(C--)
  10. {
  11. string str;
  12. cin>>str;
  13. int p,q,N,C=0,element=0;
  14. N=str.length();
  15. for(p=0;p<N;p++)
  16. {
  17. C=0;
  18. for(q=0;q<N;q++)
  19. {
  20. if(str[q]==str[p])
  21. {
  22. C++;
  23. }
  24. }
  25. if(C>1)
  26. {
  27. element=str[p];
  28. break;
  29. }
  30. }
  31. if(C==0 || element==0)
  32. cout<<".\n";
  33. else
  34. cout<<(char)element<<"\n";
  35.  
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 5488KB
stdin
4
datastructures
algorithms
smartinterviews
hackerrank
stdout
a
.
s
a