help with making a program | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

help with making a program

Hi guys, I need your help. I have to make a program in cpp: imagine an array of 3-digit numbers where every digit of that number has it's position (1-2700) if user enters a number from 1 - 2700, program should print digit that is on that place and 3-digit number it belongs to. So, if user enters for example 28, program prints number 1 that belongs to number 109. Sorry for bad english and thanks in advance.

13th Feb 2017, 10:27 AM
aleksandar
4 Respuestas
+ 1
Hey, I have found the answer: To find that 3-digit number I would do this: threeDigitNumber = (position - 1) / 3 + 100; just after that i will make a simple switch statement to find out which one digit from that number should I print. Anyways, thanks a lot!
14th Feb 2017, 9:16 PM
aleksandar
0
Hi Aleksandar, just to be sure i understand you in the right way: you have an array = int number(3); now the Numbers you are inserting have digits for example the number 947 947 123 but what do you want to print if the numer is 2700, and what should the relationship between the numbers be?
13th Feb 2017, 10:50 AM
Christian Klünter
Christian Klünter - avatar
0
2700 would be the last digit of the last 3-digit number: 9 (last 3-digit number is the 999 so the last digit of that number is 9)
13th Feb 2017, 11:21 AM
aleksandar
0
ok, so each digit will have a range of 900 numbers. First 1-900 second 901-1800 third 1801-2700 correct? if so, you cold just use a Switch case or if statement to Check the value and Set it Edit: and Sure, each number of the digit (0-9) will have a span of 90 values.
13th Feb 2017, 11:47 AM
Christian Klünter
Christian Klünter - avatar