Problem

This is a discussion on Problem within the C++ Programming forums, part of the General Programming Boards category; I have a GUI keypad All inputs are strings where user enters nums Pressing “1” Key: it will show - ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    Problem

    I have a GUI keypad
    All inputs are strings where user enters nums

    Pressing “1” Key: it will show - 000.01
    Pressing “2” Key: it will show - 000.12
    Pressing “3” Key: it will show - 001.23
    Pressing “4” Key: it will show - 012.34
    Pressing “5” Key: it will show - 123.45

    Can ne1 help me cracking the Algo

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,172
    Graphical User Interface? If so, then what platform?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    12345.0 divide by 1e[n]

    where [n] is 7 - number entered by user
    the result should be printed with format like %06.2f (or corresponding width/precision modifiers for ostream)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Or, similar to varts solution, start with a multiplier of 0.01, multiply the input with this, and multiply the multiplier by 10 for each digit that comes in.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    11
    Quote Originally Posted by Elysia View Post
    Graphical User Interface? If so, then what platform?
    i work on Qtopia , so i m dealing with QStrings not normal strings .

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    11
    Quote Originally Posted by manohar.amit View Post
    i work on Qtopia , so i m dealing with QStrings not normal strings .

    Hi Elysia
    Goddess of the Sky

    I need help I am in deep ........

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,172
    I don't know QTopia and I don't know QStrings...
    I only know good old C/C++, Win32 and MFC.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    11
    Quote Originally Posted by Elysia View Post
    I don't know QTopia and I don't know QStrings...
    I only know good old C/C++, Win32 and MFC.
    okie then how to go about it in a normal string fashion.............

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Fill the string with "000.00".
    Keep a count of how many characters you have received.
    Use a table of [0, 1, 3, 4, 5] as index, then shift each character into the index.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Nov 2007
    Posts
    11
    Quote Originally Posted by matsp View Post
    Fill the string with "000.00".
    Keep a count of how many characters you have received.
    Use a table of [0, 1, 3, 4, 5] as index, then shift each character into the index.

    --
    Mats
    everything will happen at run time !!!!!
    thats the issue

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    You already got valid answers. Move on.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21