PLS HELP!


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.

Look at the previous posts of this moron before answering!
Last edited on
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"; }
}
I hope you understand what I want.


Nope. But then, I'm thick.
Hey, lastchance, don't be so hard on yourself. I'm denser than Osmium...
I never got my $19.95.
What, Ganado, you don't like that warm, fuzzy feeling you get when you get stiffed for doing work and no payment?
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
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 ??
seeplus

YES!

but for 528 to become one variable and 474 another variable .....
Last edited on
AWESOME!

But where does 44 come from?
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


seeplus thank you!!
lastchacne it does not matter
Last edited on
Topic archived. No new replies allowed.