Language: C++

Last login: Sat Mar 21 11:12:00 on ttys000
nikhil@MacBook-Pro ~ % cd Desktop 
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp 
temp.cpp:18:21: warning: adding 'char' to a string does not append to the string
      [-Wstring-plus-int]
              s = ch+""+ s;
                  ~~^~~
temp.cpp:18:21: note: use array indexing to silence this warning
^[[A1 warning generated.
nikhil@MacBook-Pro Desktop % ./a.out     
a
4
2 1 p
1
2 2 c
1
ch.a
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a
zsh: no such file or directory: ./a
nikhil@MacBook-Pro Desktop % ./a.out  
a
4
2 1 p
1
2 2 c
1
cpa
nikhil@MacBook-Pro Desktop % clear

nikhil@MacBook-Pro Desktop % ./a.out 
a
6
2 2 a
2 1 b
1
2 2 c
1
1
aabc
nikhil@MacBook-Pro Desktop % ./a.out 
y
1
2 1 x
xy
nikhil@MacBook-Pro Desktop % vim temp.cpp
]%                                                                              nikhil@MacBook-Pro Desktop % rm temp.cpp 
nikhil@MacBook-Pro Desktop % clear





nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp 
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      vs 'int'
   queue<char> q;
               ^
temp.cpp:5:9: note: previous definition is here
    int q;
        ^
temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
   String temp = "";
   ^~~~~~
   string
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:211:65: note: 
      'string' declared here
typedef basic_string<char, char_traits<char>, allocator<char> > string;
                                                                ^
temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      union
   while(q.size() > 0)
         ~^~~~~
temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
             ~^~~~~~
temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
                        ~^~~~
temp.cpp:38:4: error: use of undeclared identifier 'ans'; did you mean 'abs'?
   ans += str;
   ^~~
   abs
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/math.h:769:1: note: 
      'abs' declared here
abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
^
temp.cpp:38:8: error: invalid operands to binary expression ('long double
      (long double) throw()' and 'std::__1::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >'))
   ans += str;
   ~~~ ^  ~~~
temp.cpp:46:2: error: expected '}'
}
 ^
temp.cpp:3:11: note: to match this '{'
int main(){
          ^
11 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      vs 'int'
   queue<char> q;
               ^
temp.cpp:5:9: note: previous definition is here
    int q;
        ^
temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
   String temp = "";
   ^~~~~~
   string
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:211:65: note: 
      'string' declared here
typedef basic_string<char, char_traits<char>, allocator<char> > string;
                                                                ^
temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      union
   while(q.size() > 0)
         ~^~~~~
temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
             ~^~~~~~
temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
                        ~^~~~
temp.cpp:46:2: error: expected '}'
}
 ^
temp.cpp:3:11: note: to match this '{'
int main(){
          ^
9 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      vs 'int'
   queue<char> q;
               ^
temp.cpp:5:9: note: previous definition is here
    int q;
        ^
temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      union
   while(q.size() > 0)
         ~^~~~~
temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
             ~^~~~~~
temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
                        ~^~~~
temp.cpp:46:2: error: expected '}'
}
 ^
temp.cpp:3:11: note: to match this '{'
int main(){
          ^
8 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      vs 'int'
   queue<char> q;
               ^
temp.cpp:5:9: note: previous definition is here
    int q;
        ^
temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      union
   while(q.size() > 0)
         ~^~~~~
temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
             ~^~~~~~
temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
                        ~^~~~
7 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
temp.cpp:7:10: error: use of undeclared identifier 'Q'
    cin>>Q;
         ^
temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      vs 'int'
   queue<char> q;
               ^
temp.cpp:5:9: note: previous definition is here
    int q;
        ^
temp.cpp:11:11: error: use of undeclared identifier 'Q'
    while(Q--){
          ^
temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      union
              q.push(ch);
              ~^~~~~
temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      union
   while(q.size() > 0)
         ~^~~~~
temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
             ~^~~~~~
temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      union
     temp += q.front(); q.pop();
                        ~^~~~
9 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:6:10: error: use of undeclared identifier 's'
    cin>>s;
         ^
1 error generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out 
a
4
2 1 p
1
2 2 c
1
zsh: segmentation fault  ./a.out
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out 
a
4
2 1 p
1
2 2 c
1
zsh: segmentation fault  ./a.out
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out 
a
4
2 1 p
1
2 2 c
1
acp
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
temp.cpp:35:62: error: use of undeclared identifier 'ch'
   while(q.size() > 0){ char c = q.front(); q.pop(); temp += ch;}
                                                             ^
temp.cpp:38:59: error: use of undeclared identifier 'ch'
   while(s.size() > 0){ char c= s.top(); s.pop(); temp += ch;}
                                                          ^
2 errors generated.
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out 
a
4
2 1 p
1
2 2 c
1
acp
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out 
a                                                         
4
2 1 p
1
2 2 c
1
zsh: segmentation fault  ./a.out
nikhil@MacBook-Pro Desktop % vim temp.cpp
nikhil@MacBook-Pro Desktop % g++ temp.cpp
nikhil@MacBook-Pro Desktop % ./a.out     
a
4
2 1 p
1
2 2 c
1
cpa
nikhil@MacBook-Pro Desktop % vim temp.cpp

#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int Q;
    cin>>str;
    cin>>Q;
    bool r_flag= false;
    queue<char> q;
    stack<char> s;
    while(Q--){
      int Ti;
      cin>>Ti;
      if(Ti == 1){
        r_flag = !r_flag;
      }
      else{
          int Fi; char ch;
          cin>>Fi>>ch;
          if(Fi == 1 && !r_flag){
              s.push(ch);
          }
          if(Fi == 1 && r_flag){
"temp.cpp" 43L, 889C


Compiler output:
a.cc:2:7: error: stray '@' in program
    2 | nikhil@MacBook-Pro ~ % cd Desktop
      |       ^
a.cc:3:7: error: stray '@' in program
    3 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:4:7: error: stray '@' in program
    4 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:5:33: warning: multi-character character constant [-Wmultichar]
    5 | temp.cpp:18:21: warning: adding 'char' to a string does not append to the string
      |                                 ^~~~~~
a.cc:11:7: error: stray '@' in program
   11 | nikhil@MacBook-Pro Desktop % ./a.out
      |       ^
a.cc:19:7: error: stray '@' in program
   19 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:20:7: error: stray '@' in program
   20 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:21:7: error: stray '@' in program
   21 | nikhil@MacBook-Pro Desktop % ./a
      |       ^
a.cc:23:7: error: stray '@' in program
   23 | nikhil@MacBook-Pro Desktop % ./a.out
      |       ^
a.cc:31:7: error: stray '@' in program
   31 | nikhil@MacBook-Pro Desktop % clear
      |       ^
a.cc:33:7: error: stray '@' in program
   33 | nikhil@MacBook-Pro Desktop % ./a.out
      |       ^
a.cc:43:7: error: stray '@' in program
   43 | nikhil@MacBook-Pro Desktop % ./a.out
      |       ^
a.cc:48:7: error: stray '@' in program
   48 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:49:87: error: stray '@' in program
   49 | ]%                                                                              nikhil@MacBook-Pro Desktop % rm temp.cpp
      |                                                                                       ^
a.cc:50:7: error: stray '@' in program
   50 | nikhil@MacBook-Pro Desktop % clear
      |       ^
a.cc:56:7: error: stray '@' in program
   56 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:57:7: error: stray '@' in program
   57 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:61:66: warning: multi-character literal with 11 characters exceeds 'int' size of 4 bytes
   61 | temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      |                                                                  ^~~~~~~~~~~~~
a.cc:62:10: warning: multi-character character constant [-Wmultichar]
   62 |       vs 'int'
      |          ^~~~~
a.cc:68:51: warning: multi-character character constant [-Wmultichar]
   68 | temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:72:51: warning: multi-character character constant [-Wmultichar]
   72 | temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:76:41: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   76 | temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
      |                                         ^~~~~~~~
a.cc:76:64: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   76 | temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
      |                                                                ^~~~~~~~
a.cc:81:7: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   81 |       'string' declared here
      |       ^~~~~~~~
a.cc:84:51: warning: multi-character character constant [-Wmultichar]
   84 | temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:88:51: warning: multi-character character constant [-Wmultichar]
   88 | temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:92:51: warning: multi-character character constant [-Wmultichar]
   92 | temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:96:52: warning: multi-character character constant [-Wmultichar]
   96 | temp.cpp:38:4: error: use of undeclared identifier 'ans'; did you mean 'abs'?
      |                                                    ^~~~~
a.cc:96:72: warning: multi-character character constant [-Wmultichar]
   96 | temp.cpp:38:4: error: use of undeclared identifier 'ans'; did you mean 'abs'?
      |                                                                        ^~~~~
a.cc:101:7: warning: multi-character character constant [-Wmultichar]
  101 |       'abs' declared here
      |       ^~~~~
a.cc:104:62: warning: missing terminating ' character
  104 | temp.cpp:38:8: error: invalid operands to binary expression ('long double
      |                                                              ^
a.cc:104:62: error: missing terminating ' character
  104 | temp.cpp:38:8: error: invalid operands to binary expression ('long double
      |                                                              ^~~~~~~~~~~~
a.cc:105:28: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  105 |       (long double) throw()' and 'std::__1::string' (aka 'basic_string<char,
      |                            ^~~~~~~~~~
a.cc:105:51: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  105 |       (long double) throw()' and 'std::__1::string' (aka 'basic_string<char,
      |                                                   ^~~~~~~~~~~~~~~~~~~~
a.cc:106:43: warning: missing terminating ' character
  106 |       char_traits<char>, allocator<char> >'))
      |                                           ^
a.cc:106:43: error: missing terminating ' character
  106 |       char_traits<char>, allocator<char> >'))
      |                                           ^~~
a.cc:116:7: error: stray '@' in program
  116 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:117:7: error: stray '@' in program
  117 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:121:66: warning: multi-character literal with 11 characters exceeds 'int' size of 4 bytes
  121 | temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      |                                                                  ^~~~~~~~~~~~~
a.cc:122:10: warning: multi-character character constant [-Wmultichar]
  122 |       vs 'int'
      |          ^~~~~
a.cc:128:51: warning: multi-character character constant [-Wmultichar]
  128 | temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:132:51: warning: multi-character character constant [-Wmultichar]
  132 | temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:136:41: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  136 | temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
      |                                         ^~~~~~~~
a.cc:136:64: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  136 | temp.cpp:34:4: error: unknown type name 'String'; did you mean 'string'?
      |                                                                ^~~~~~~~
a.cc:141:7: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  141 |       'string' declared here
      |       ^~~~~~~~
a.cc:144:51: warning: multi-character character constant [-Wmultichar]
  144 | temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:148:51: warning: multi-character character constant [-Wmultichar]
  148 | temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:152:51: warning: multi-character character constant [-Wmultichar]
  152 | temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:163:7: error: stray '@' in program
  163 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:164:7: error: stray '@' in program
  164 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:168:66: warning: multi-character literal with 11 characters exceeds 'int' size of 4 bytes
  168 | temp.cpp:9:16: error: redefinition of 'q' with a different type: 'queue<char>'
      |                                                                  ^~~~~~~~~~~~~
a.cc:169:10: warning: multi-character character constant [-Wmultichar]
  169 |       vs 'int'
      |          ^~~~~
a.cc:175:51: warning: multi-character character constant [-Wmultichar]
  175 | temp.cpp:24:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:179:51: warning: multi-character character constant [-Wmultichar]
  179 | temp.cpp:27:16: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:183:51: warning: multi-character character constant [-Wmultichar]
  183 | temp.cpp:35:11: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:187:51: warning: multi-character character constant [-Wmultichar]
  187 | temp.cpp:36:15: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:191:51: warning: multi-character character constant [-Wmultichar]
  191 | temp.cpp:36:26: error: member reference base type 'int' is not a structure or
      |                                                   ^~~~~
a.cc:202:7: error: stray '@' in program
  202 | nikhil@MacBook-Pro Desktop % vim temp.cpp
      |       ^
a.cc:203:7: error: stray '@' in program
  203 | nikhil@MacBook-Pro Desktop % g++ temp.cpp
      |       ^
a.cc:207:66: warning: multi-character literal with 11 chara