Cutting rod Dynamic Programming (to maximize the no of segments)

https://practice.geeksforgeeks.org/problems/cutted-segments/0

My solution for this ques is -

#include
#include<bits/stdc++.h>
using namespace std;
int rod(int a[],int n){

int tab[3][n+1];
int i,j;
for(i=0;i<3;i++){
    tab[i][0]=0;
}
for(i=1;i<=n;i++){
    if(i<a[0]) tab[0][i]=0;
    else if (i==a[0]) tab[0][i]=1;
    else{
        if(i%a[0]==0) tab[0][i]=i/a[0];
        else tab[0][i]=0;
    }
}
for(i=1;i<3;i++){
    for(j=1;j<=n;j++){
        if(j>=a[i]){
            tab[i][j]=max(tab[i-1][j],1+tab[i][j-a[i]]);
        }
        else{
            tab[i][j]=tab[i-1][j];
        }
    }
}
for(i=0;i<3;i++){
    for(j=0;j<=n;j++){
        cout<<tab[i][j]<<" ";
    }
    cout<<endl;
}
return tab[2][n];

}

int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[3];
cin>>a[0]>>a[1]>>a[2];
//sort(a,a+n);
int b[3];
if((a[0]>=a[1])&&(a[0]>=a[2])){
b[2]=a[0];
b[1]=max(a[1],a[2]);
b[0]=min(a[1],a[2]);
}
if((a[1]>=a[0])&&(a[1]>=a[2])){
b[2]=a[1];
b[1]=max(a[0],a[2]);
b[0]=min(a[0],a[2]);
}
if((a[2]>=a[1])&&(a[2]>=a[0])){
b[2]=a[2];
b[1]=max(a[1],a[0]);
b[0]=min(a[1],a[0]);
}
for(int y=0;y<3;y++) cout<<b[y];
cout<<endl;
cout<<rod(b,n)<<endl;
}
//code
return 0;
}

I am unable to find the problem with this solution. Please check this once.