#include<bits/stdc++.h>
using namespace std;
struct Router
{
float sum;
int ind;
};
bool comp(Router r1, Router r2)
{
return r1.sum < r2.sum;
}
int main()
{
while(1)
{
int n;
cin>>n;
if(n==0)
break;
float matrix[n][n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>matrix[i][j];
int newRouters[n];
for(int i=0;i<n;i++)
cin>>newRouters[i];
Router routers[n];
for(int i=0;i<n;i++)
{
routers[i].ind = i;
routers[i].sum = 0.0;
}
for(int i=0;i<n;i++)
{
float trafficSum = 0.0;
for(int j=0;j<n;j++)
trafficSum += abs(matrix[i][j]);
routers[i].sum = trafficSum;
}
sort(routers, routers+n, comp);
sort(newRouters, newRouters + n);
int assign[n];
for(int i=0;i<n;i++)
assign[routers[i].ind] = newRouters[i];
for(int i=0;i<n;i++)
cout<<(i+1)<<"-"<<assign[i]<<" ";
cout<<endl;
}
}
I can't seem to find the issue that is causing Command terminated by signal 11 in my code. Hence i am a newbie with coding so, i can't really find the error in the codes. BTW this is in c++ code. Just trying to learn from mistake right now . I don't have experience using debugger does debugger helps to find the issue on this ?