Blank_0014

Untitled

Jul 18th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;   
  3.  
  4. int signSeq(string operators) {
  5.     int max = 2, operandCount = 0, i = 1;
  6.     char recentChar = 0;
  7.     for(char s:operators)
  8.         if(s != '='){
  9.             operandCount = s==recentChar ? ++operandCount > max ? ++max : operandCount : 2;
  10.             recentChar = s;
  11.         }
  12.     return !operandCount ? 1 : max;
  13. }
  14. int main() {
  15.     int T;
  16.     string s;
  17.     cin >> T;
  18.     while(T --> 0){
  19.         cin >> s;
  20.         cout << signSeq(s) << endl;
  21.     }
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment