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