I have a problem in my code. In Xcode or using the C++11 compiler, this code works well. However, when I am submitting this code to an Online Judge, the verdict shows "Compile Error". I think they use the C++4.7.1 compiler, which when I tried to compile it (using Ideone), it says:
prog.cpp: In function 'void printArray(int)': prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type prog.cpp:27: error: 'void*' is not a pointer-to-object type
This makes no sense because there are no void*
's anywhere in this program.
I don't have any inkling what to change though. It would be great if you guys help me to solve this. Below is my code:
#include <iostream> #include <math.h> #include <cmath> #include <tgmath.h> int array[10] = {1,2,3,4,5,6,7,8,9}; int initial = 1; int tmp; int total[500]; using namespace std; void swap(int x, int y){ int temp = array[x]; array[x]=array[y]; array[y]=temp; return; } void printArray(int size){ int i; for (i=0;i<size;i++){ //cout<<array[i]<<" "; tmp= array[i]; tmp= (tmp* (pow(10.0,(size-i-1)))); // <--- Error here total[initial]=total[initial]+ tmp; } initial++; tmp=0; //cout<<endl; } void permute(int k,int size){ int i; if (k==0) printArray(size); else{ for (i=k-1;i>=0;i--){ swap(i,k-1); permute(k-1,size); swap(i,k-1); } } return; } void quickSort(int arr[], int left, int right) { int i = left, j = right; int tmp; int pivot = arr[(left + right) / 2]; while (i <= j) { while (arr[i] < pivot) i++; while (arr[j] > pivot) j--; if (i <= j) { tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i++; j--; } }; if (left < j) quickSort(arr, left, j); if (i < right) quickSort(arr, i, right); } int main(){ int countertest; cin>>countertest; int ak, asize; for(int a= 0; a<countertest; a++){ initial = 1; std::fill(total, total+500, 0); cin>>asize>>ak; permute(asize,asize); quickSort(total, 1, initial-1); int arraydex [10000], temp = total[ak]; for(int z = asize; z>=0; z--){ arraydex[z] = temp % 10; temp /= 10; } for(int bc = 1; bc<=asize; bc++){ cout<<arraydex[bc]<<" "; } cout<<endl; } return 0; }