Refreezer

Untitled

Apr 16th, 2021
563
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int solve(const char* c){
  6.    
  7.     int sum = 0;
  8.  
  9.     while (*c != '\0')
  10.     {
  11.         char ch = *c;
  12.         int sign = 1;
  13.         if (ch == ':')
  14.         {
  15.             if (*(c + 1) == '\0')
  16.             {
  17.                 return sum;
  18.             }
  19.  
  20.             if (*(c + 1) != ')' && *(c + 1) != '(')
  21.             {
  22.                 c++;
  23.                 continue;
  24.             }
  25.  
  26.             if (*(c + 1) == '(')
  27.             {
  28.                 sign = -1;
  29.             }
  30.             else
  31.             {
  32.                 sign = 1;
  33.             }
  34.            
  35.             char parenthesis = *(c + 1);
  36.            
  37.             c++;
  38.            
  39.             while (*c == parenthesis)
  40.             {
  41.                 sum += sign;
  42.                 //cout << parenthesis << sum << endl;
  43.                 c++;
  44.             }
  45.  
  46.             continue;
  47.         }
  48.  
  49.         c++;    
  50.     }
  51.  
  52.     return sum;
  53. }
  54.  
  55. int main(){
  56.     string s = "123ssdqwe: :123:))((:())) (((\0";
  57.     const char* arr = s.c_str();
  58.     cout << solve(arr) << endl;
  59. }
  60.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×