0

Can somone help

Hey guys I found an intersting task in my c++ book that cought my attention, It goes like this :[ N decimal fights. input is interrupted when 0 is entered, the program should work in such a way as to take part of the number after the dot and print both boroj and ASCII value of that number in the range of 32-126 Input 16.35 128.92 452.1024 0 Output 35- # 92 - 1024 ] I am thinking about it for a couple of hours form now but can't figure how to solve it, can somone help?

15th Feb 2021, 11:35 AM
Dr. Alien
Dr. Alien - avatar
3 Answers
+ 5
Dr. Alien , you can use a while loop for input one number in each iteration and keep it as string. take the number and check: â–Șif it is 0 - then use break and terminate the program if it is not 0: â–Șuse the string and spit it at the "." (*1) â–Ștake the right part and output it, followed by the numbers ascii representation filtered to only numbers from 32 upto 126 (*1) an other way could be to find the "." in the string, and use this index +1 to get the right part of the string and process it like described above happy coding and good success
15th Feb 2021, 12:11 PM
Lothar
Lothar - avatar
+ 2
You can input the data as a string lines till received „0“ . Then search in each string for the dot „.“ and print all characters after that. Try to implement this algorithmus here on Playground and provide us the link for your attempt if you need additional help.
15th Feb 2021, 11:54 AM
JaScript
JaScript - avatar
0
#include <iostream> using namespace std; int main() { double x; cin>>x; x -= (int)x; int r = x * 1000000; // 6 digits after dot, if you want more u may use a strig or something while (r % 10 == 0) r /= 10; cout << r << " " << (char)r; return 0; }
15th Feb 2021, 12:06 PM
Alpha Zero
Alpha Zero - avatar