Here is my code for the problem ’ Form Biggest Number ':
#include
#include<math.h>
#include
using namespace std;
bool compare(int n1,int n2) {
int n1Digits = 0;
int temp = n1;
while(temp>0) {
n1Digits++;
temp /= 10;
}
int n2Digits = 0;
temp = n2;
while(temp>0) {
n2Digits++;
temp /= 10;
}
int num1 = n1pow(10,n2Digits) + n2;
int num2 = n2pow(10,n1Digits) + n1;
return (num1>num2)?0:1;
}
int main() {
int t;
cin>>t;
while(t>0) {
int n;
cin>>n;
int *input = new int[n];
for(int i=0;i<n;i++) {
cin>>input[i];
}
sort(input,input+n,compare);
for(int i=0;i<n;i++) {
cout<<input[i];
}
cout<<endl;
delete [] input;
t–;
}
return 0;
}
Please tell me what am i doing wrong
I am only getting one test case correct