Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. its showing Error ?

its showing Error ?

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nisha00000
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • N nisha00000

      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

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      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_

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups