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. Diffcult question

Diffcult question

Scheduled Pinned Locked Moved C / C++ / MFC
c++xmltutorialquestioncareer
4 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 last week i attend one interview ,they asking one question in MFC . i have one txt file which is contains.... numbers 1 2 3 4 5 my question is how to sort in 3 digit form like this: 123 134 145 234 245 251 345 351 312 451 412 423 512 523 534 i need this kind of output in xml file . i need this kind of way ....i hav no idea abt how to get output.. thanks and regards Nisha

    A 1 Reply Last reply
    0
    • N nisha00000

      hi last week i attend one interview ,they asking one question in MFC . i have one txt file which is contains.... numbers 1 2 3 4 5 my question is how to sort in 3 digit form like this: 123 134 145 234 245 251 345 351 312 451 412 423 512 523 534 i need this kind of output in xml file . i need this kind of way ....i hav no idea abt how to get output.. thanks and regards Nisha

      A Offline
      A Offline
      AndreFratelli
      wrote on last edited by
      #2

      You can use something like this:

      #define next(i) ((i) < 5 ? (i) + 1 : 1)
      #define previous(i) ((i) > 1 ? (i) - 1 : 5)

      int main()
      {
      unsigned 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;
      

      }

      The "next" macro increments a value until it reaches 5. When such happens, it returns to 1. The "previous" macro does the opposite, when the value reaches 1 it returns to 5. regards

      N 1 Reply Last reply
      0
      • A AndreFratelli

        You can use something like this:

        #define next(i) ((i) < 5 ? (i) + 1 : 1)
        #define previous(i) ((i) > 1 ? (i) - 1 : 5)

        int main()
        {
        unsigned 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;
        

        }

        The "next" macro increments a value until it reaches 5. When such happens, it returns to 1. The "previous" macro does the opposite, when the value reaches 1 it returns to 5. regards

        N Offline
        N Offline
        nisha00000
        wrote on last edited by
        #3

        yes thanks ..but i want to this output into XML format...

        A 1 Reply Last reply
        0
        • N nisha00000

          yes thanks ..but i want to this output into XML format...

          A Offline
          A Offline
          AndreFratelli
          wrote on last edited by
          #4

          In what format? You can always output the XML tags with the values... I just don't know for sure which tags you intend on using. Regards Fratelli

          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