Output error of String sort please verify

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
string max="";
cout<<endl;
string A[n];
for(int i=0;i<n;i++)
{
cin>>A[i];
cout<<endl;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n-1-i;j++)
{
int x=A[j].compare(A[j+1]);
if(x>0)
{
string t=A[j+1];
A[j+1]=A[j];
A[j]=t;
}
}
}
for(int i=0;i<n;i++)
{
cout<<A[i]<<endl;
}

return 0;

}
output is
apple
bat
batman
please resolve

hello @rohit_26_05

pls save this code at coding blocks ide and share its link with me