Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. void checkForOperators(string line){
  2.     for (int i = 0; i < line.length(); i++){
  3.         //Check for compound assignment operators and increment/decrement operators
  4.         if (line.substr(i,2) == "+="
  5.             || line.substr(i,2) == "-="
  6.             || line.substr(i,2) == "*="
  7.             || line.substr(i,2) == "/="
  8.             || line.substr(i,2) == "+="
  9.             || line.substr(i,2) == "%="
  10.             || line.substr(i,2) == ">>="
  11.             || line.substr(i,2) == "&="
  12.             || line.substr(i,2) == "^="
  13.             || line.substr(i,2) == "|="
  14.             || line.substr(i,2) == "++"
  15.             || line.substr(i,2) == "--"
  16.             ){
  17.                 if (!search(line.substr(i,2), operators)){
  18.                     operators.push_back(line.substr(i,2));
  19.                 }
  20.  
  21.         }
  22.         if (   (line.substr(i,1) == "+" && line.substr(i,2) != "+=")
  23.             || (line.substr(i,1) == "-" && line.substr(i,2) != "-=")
  24.             || (line.substr(i,1) == "*" && line.substr(i,2) != "*=")
  25.             || (line.substr(i,1) == "/" && line.substr(i,2) != "/=")
  26.             || (line.substr(i,1) == "%" && line.substr(i,2) != "%=")
  27.             || (line.substr(i,1) == "=")
  28.             ){
  29.                 if (!search(line.substr(i,1), operators)){
  30.                     operators.push_back(line.substr(i,1));
  31.                 }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement