Can anyone tell me what is wrong in my code

Question name - Valid Expression ,of contest no. 78 div 4.

#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t–){
int n,x,d=1;
string s="";
cin>>n>>x;
if(x>0){
for(int i=0;i<n;i++){
if(d<x){
s=s+ “+”;
d++;
}
else if(d==x)
s=s+"";
}
if(s=="")
cout<<- 1<<endl;
else
cout<<s<<endl;
}
else{
for(int i=0;i<n;i++){
if(d<x){
s=s+"-";
d–;
}
else if(d==x){
s=s+"
";
}
}
if(s=="")
cout<<-1<<endl;
else
cout<<s<<endl;
}
}
return 0;
}

in while loop you need to put t-- not t- .
and in line 30 there is variable d which is decrementing so it will be d–.
sorry but I was able to find only these two mistakes .
something is wrong with the code and it has gotten stuck in infinite loop.

1 Like

No there are 2 – there.