PLS HELP!

Mar 24, 2021 at 5:33pm

I need help!
I need to make the following program:
First when I print the numbers (example 5280474088) the program should extract all the numbers from the string to the first 0 (in this case it is 528). and if it were further 88). The separated numbers 528 should be converted into one number, if you would like to divide this number 528 by the number 44 so that I can get 12. The same applies to other numbers.

I hope you understand what I want. Thank you.

Mar 24, 2021 at 5:37pm
Look at the previous posts of this moron before answering!
Last edited on Mar 24, 2021 at 5:42pm
Mar 24, 2021 at 5:47pm
You want us to write the code for you for free, and you will take the credit for it.

It will cost you:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <cctype>
#include <limits>

int main()
{
   std::cout << "Do you want someone to do all the work for you? ";
   char answer{};
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }
}
Mar 24, 2021 at 5:50pm
I hope you understand what I want.


Nope. But then, I'm thick.
Mar 24, 2021 at 6:19pm
Hey, lastchance, don't be so hard on yourself. I'm denser than Osmium...
Mar 24, 2021 at 6:19pm
I never got my $19.95.
Mar 24, 2021 at 6:21pm
What, Ganado, you don't like that warm, fuzzy feeling you get when you get stiffed for doing work and no payment?
Mar 24, 2021 at 11:47pm
this makes chef seem coherent. Well played!
what happent to 474, and where did 44 come from? why do you want 12?
Last edited on Mar 24, 2021 at 11:49pm
Mar 25, 2021 at 10:21am
hope you understand what I want.


Nope. Extracting numbers before a 0 would give 528 474. Do you mean extract the numbers separated by 0 which would give 528 474 88 ??
Mar 25, 2021 at 5:11pm
seeplus

YES!

but for 528 to become one variable and 474 another variable .....
Last edited on Mar 25, 2021 at 5:13pm
Mar 25, 2021 at 5:23pm
AWESOME!

But where does 44 come from?
Mar 25, 2021 at 5:24pm
With each 'part' of the data as a vector element and assuming that the original string is a number, consider:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

int main()
{
	const std::string num {"5280474088"};

	std::vector<int> nums;
	std::istringstream iss(num);

	for (std::string n; std::getline(iss, n, '0'); nums.push_back(std::stoi(n)));

	for (const auto& n : nums)
		std::cout << n << "  " << n / 44 << '\n';
}


which displays:


528  12
474  10
88  2


Mar 25, 2021 at 5:34pm
seeplus thank you!!
lastchacne it does not matter
Last edited on Mar 25, 2021 at 5:36pm
Topic archived. No new replies allowed.