fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. string s;
  5.  
  6. string sub1(){
  7. string res = "";
  8. char tam = ' ';
  9. for(int i = 0; i < (int)s.size(); i++){
  10. if (res.empty() || s[i] != tam) {
  11. res.push_back(s[i]);
  12. tam = s[i];
  13. }
  14. }
  15. return res;
  16. }
  17.  
  18. string sub2(){
  19. string res = "";
  20. bool C = false;
  21. char tam = ' ';
  22. for(int i = 0; i < (int)s.size(); i++){
  23. if (s[i] == '*') {
  24. C = true;
  25. } else {
  26. if (res.empty() || s[i] != tam || C) {
  27. res.push_back(s[i]);
  28. tam = s[i];
  29. }
  30. C = false;
  31. }
  32. }
  33. return res;
  34. }
  35.  
  36. int main() {
  37. ios_base::sync_with_stdio(false);
  38. cin.tie(NULL);cout.tie(NULL);
  39. freopen("TINNHAN.INP", "r", stdin);
  40. freopen("TINNHAN.OUT", "w", stdout);
  41. cin>>s;
  42. bool flag = false;
  43. for(int i = 0; i < (int)s.size(); i++)
  44. if (s[i] == '*'){
  45. flag = 1;
  46. break;
  47. }
  48.  
  49.  
  50. if (!flag){
  51. cout<<sub1();
  52. }
  53. else {
  54. cout<<sub2();
  55. }
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty