0
Задача на C
Даны два натуральных числа M и N. Вывести младшую цифру целой части и старшую цифру дробной части числа M/N Младшая цифра = последняя цифра Старшая = первая цифра
2 Réponses
0
You can convert the result of M/N into a string and then use array manipulation to locate the desired characters of the string. You can use sprintf() to perform the string conversion into a pre-defined char array.
0
On further reflection, maybe a mathematical approach is better.
1. Multiply M/N by 10 to shift the decimal point to the right by 1 digit.
2. Convert it to integer.
3. Find the modulo base 100.
The resulting one or two digits are the solution. (If it has only one digit, then it means the first number is 0). You have isolated the digits. Now you can work with the number to break it up and display it however you want.