fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. bool f (char x)
  6. {
  7. return ((x<='9') || (x>='a' && x<='z') || (x>='A' && x<='Z')); //Проверяем является ли символ частью числа или переменной.
  8. }
  9.  
  10. int main()
  11. {
  12. short int k = 0;
  13. char s[250];
  14. while (cin>>s[k])
  15. {
  16. k++;
  17. }
  18.  
  19. char * c = strpbrk (s+1, "+-*");
  20. short int n = 0;
  21. while (c!=NULL)
  22. {
  23. if (f(s[c-1 - s]) && f(s[c+1-s])&&(c-s!=k-1))
  24. {
  25. n++;
  26. }
  27. s[c-s] = ' ';
  28. c = strpbrk (s+1, "+-*");
  29. }
  30. cout<<n;
  31. return 0;
  32. }
Success #stdin #stdout 0s 3464KB
stdin
2+6*6
stdout
2