#include
using namespace std;
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
bool comaprator(string a,string b){
if(b.find(a) != std::string::npos || a.find(b) != std::string::npos){
return a>b;
}else{
return a<b;
}
}
void sortString(string *ss,int n){
sort(ss,ss+n,comaprator);
for (int i = 0; i < n; ++i)
{
cout << ss[i] <<" ";
}
cout << endl;
}
int main(){
int n;
cin >> n;
string s[n];
for(int i=0;i<n;i++){
getline(cin,s[i]);
}
sortString(s,n);
return 0;
}
It says compilation error and I can’t find to fix it even i replace sort with qsort.
Compiling failed with exitcode 1, compiler output:
prog.cpp: In function ‘void sortString(std::__cxx11::string*, int)’:
prog.cpp:26:5: error: ‘sort’ was not declared in this scope
sort(ss,ss+n,comaprator);
^~~~
prog.cpp:26:5: note: suggested alternative: ‘qsort’
sort(ss,ss+n,comaprator);
^~~~
qsort