Guest User

Untitled

a guest
Dec 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int arr[1000];
  4.  
  5. string removeSpaces(string str)
  6. {
  7. stringstream ss;
  8. string temp;
  9. ss << str;
  10. str = "";
  11. while (!ss.eof())
  12. {
  13. ss >> temp;
  14. str = str + temp;
  15. }
  16. return str;
  17. }
  18.  
  19. int main()
  20. {
  21. string s;
  22. getline(cin,s);
  23. string ss = removeSpaces(s);
  24. int length = ss.length();
  25.  
  26. int count = 1 ;
  27. int comma = 0;
  28. int k = 0;
  29.  
  30. for(int i = 1 ; i < ss.length() - 1 ; i++){
  31. if(ss.at(i) == ','){
  32. comma++;
  33. }
  34. if(ss.at(i) != ','){
  35. arr[k] = ss.at(i);
  36. k++;
  37. }
  38. }
  39.  
  40. sort(arr , arr + k);
  41. if(arr[0] == 0){
  42. cout << 0 << endl;
  43. exit(0);
  44. }
  45.  
  46. int loop = 0;
  47. int poop = 0;
  48. for(int i = 0 ; i < k ; i++){
  49. for(int j = i + 1 ; j < k ; j++){
  50. if(arr[i] != arr[j]){
  51. count++;
  52. i = j;
  53. i--;
  54. break;
  55. }
  56. }
  57. }
  58.  
  59. cout << count << endl;
  60. return 0;
  61. }
Add Comment
Please, Sign In to add comment