its showing Error ?
-
hi this is my code ..its working good in 3digit sorting algorithm. #define next(i) ((i) < 5 ? (i) + 1 : 1) #define previous(i) ((i) > 1 ? (i) - 1 : 1) int main() { unsigned long i, aux, j, cnt; for (i=1 ; i<6 ; i++) { for (aux = next(i) ; aux != previous(i) ; aux = next(aux)) { cout << i << aux << next(aux) << endl; } } return 0; } But, i replaced 5 into 100 ..its showing wrong sorting why? #define next(i) ((i) < 100 ? (i) + 1 : 1) #define previous(i) ((i) > 1 ? (i) - 1 : 1) int main() { unsigned long i, aux, j, cnt; for (i=1 ; i<101 ; i++) { for (aux = next(i) ; aux != previous(i) ; aux = next(aux)) { cout << i << aux << next(aux) << endl; } } return 0; } Thanks and Regards Nisha.S
-
hi this is my code ..its working good in 3digit sorting algorithm. #define next(i) ((i) < 5 ? (i) + 1 : 1) #define previous(i) ((i) > 1 ? (i) - 1 : 1) int main() { unsigned long i, aux, j, cnt; for (i=1 ; i<6 ; i++) { for (aux = next(i) ; aux != previous(i) ; aux = next(aux)) { cout << i << aux << next(aux) << endl; } } return 0; } But, i replaced 5 into 100 ..its showing wrong sorting why? #define next(i) ((i) < 100 ? (i) + 1 : 1) #define previous(i) ((i) > 1 ? (i) - 1 : 1) int main() { unsigned long i, aux, j, cnt; for (i=1 ; i<101 ; i++) { for (aux = next(i) ; aux != previous(i) ; aux = next(aux)) { cout << i << aux << next(aux) << endl; } } return 0; } Thanks and Regards Nisha.S
That is because you didn't try to get into the code you were given yesterday (that works with 3 digits) :sigh: . It would be better for you to understand the algorithm for 3 digits before you move ahead to implement the second one. BTW what happens when you try and debug your new code? And the error displayed is...........................
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_