用来测试notepad++是否可以编译c++的代码
#include <iostream> #include <cstdio> #include <vector> #include <string> using namespace std; bool isValid(string s) { vector<char>res; int len = s.size(); for (int i=0;i<len;i++) { if ((int)s[i]==40||(int)s[i]==123||(int)s[i]==91) res.push_back(s[i]); else { int reslen=res.size(); if (reslen==0) return false; if((int)s[i]==41) { if((int)res[reslen-1]==40) res.pop_back(); else return false; } if((int)s[i]==125) { if((int)res[reslen-1]==123) res.pop_back(); else return false; } if((int)s[i]==93) { if((int)res[reslen-1]==91) res.pop_back(); else return false; } } } if (res.size()==0) return true; else return false; } int main() { // int a,b; // cin>>a>>b; // printf("%d",a+b); string instr="{[[][)]]}"; bool res=isValid(instr); cout <<res<< endl; return 0; }
1、先按照链接https://blog.csdn.net/qq_31640513/article/details/71038603 配置notepad++
2、配置上述代码,命名为x.cpp