Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int signSeq(string operators) {
- int max = 2, operandCount = 0, i = 1;
- char recentChar = 0;
- for(char s:operators)
- if(s != '='){
- operandCount = s==recentChar ? ++operandCount > max ? ++max : operandCount : 2;
- recentChar = s;
- }
- return !operandCount ? 1 : max;
- }
- int main() {
- int T;
- string s;
- cin >> T;
- while(T --> 0){
- cin >> s;
- cout << signSeq(s) << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment