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#
  4. Number position

Number position

Scheduled Pinned Locked Moved C#
8 Posts 7 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.
  • D Offline
    D Offline
    D i x y
    wrote on last edited by
    #1

    The number to be encoded is 173946. Starting from the right side of the number (the units position), collect all of the odd position digits (i.e. digit 1, digit 3, digit 5, etc.) and create a new number leaving the digits in their left to right order. The new number would be 796.

    J P CPalliniC G 4 Replies Last reply
    0
    • D D i x y

      The number to be encoded is 173946. Starting from the right side of the number (the units position), collect all of the odd position digits (i.e. digit 1, digit 3, digit 5, etc.) and create a new number leaving the digits in their left to right order. The new number would be 796.

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      Dixy wrote:

      The new number would be 796.

      Correct. Now do your own homework.

      B 1 Reply Last reply
      0
      • D D i x y

        The number to be encoded is 173946. Starting from the right side of the number (the units position), collect all of the odd position digits (i.e. digit 1, digit 3, digit 5, etc.) and create a new number leaving the digits in their left to right order. The new number would be 796.

        P Offline
        P Offline
        Programm3r
        wrote on last edited by
        #3

        Well let see .... I think you can start with a for or foreach loop. And then you can move on to Google to get some more information. Logic makes the world go around .... Regards,


        The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^

        B 1 Reply Last reply
        0
        • J J4amieC

          Dixy wrote:

          The new number would be 796.

          Correct. Now do your own homework.

          B Offline
          B Offline
          Brady Kelly
          wrote on last edited by
          #4

          :laugh: And you're in trouble if you need help with this homework question.  Serious trouble.

          Semicolons: The number one seller of ostomy bags world wide. - dan neely

          1 Reply Last reply
          0
          • D D i x y

            The number to be encoded is 173946. Starting from the right side of the number (the units position), collect all of the odd position digits (i.e. digit 1, digit 3, digit 5, etc.) and create a new number leaving the digits in their left to right order. The new number would be 796.

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            The problem is well defined, hence: good luck! :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • P Programm3r

              Well let see .... I think you can start with a for or foreach loop. And then you can move on to Google to get some more information. Logic makes the world go around .... Regards,


              The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^

              B Offline
              B Offline
              Brady Kelly
              wrote on last edited by
              #6

              I would go with a while loop:

              while not num.BON
              {
              etc.
              }

              where BON is Beginning Of Number...:suss:

              Semicolons: The number one seller of ostomy bags world wide. - dan neely

              1 Reply Last reply
              0
              • D D i x y

                The number to be encoded is 173946. Starting from the right side of the number (the units position), collect all of the odd position digits (i.e. digit 1, digit 3, digit 5, etc.) and create a new number leaving the digits in their left to right order. The new number would be 796.

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                I find it fun to take some simple homework assignment like this and try to turn it into a one-liner. ;) int encode(int v){return 0<v?0xa*encode(v/0x64)+v%0xa:v-v;}

                Despite everything, the person most likely to be fooling you next is yourself.

                C 1 Reply Last reply
                0
                • G Guffa

                  I find it fun to take some simple homework assignment like this and try to turn it into a one-liner. ;) int encode(int v){return 0<v?0xa*encode(v/0x64)+v%0xa:v-v;}

                  Despite everything, the person most likely to be fooling you next is yourself.

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  It would be SO awesome if he submits this....

                  Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  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