Just to attract your attention. :cheesy: :lol: :cool: ;)
Here's the problem:
I have this string "flames". Then I get a number from earlier part of myprogram. Let the number be 4. Now 'm' is the 4th character. This should be removed. Then the remaining string is "flaes". Now 'e is the fourth char. This should be removed. Finally only one character remains standing. This character should be displayed.

What happens when the length of the string is less than the index you're removing from? Show me this hypothetical algorithm to it's logical conclusion. For example, remove 'e'. Then remove 's'. Then what?

I dunno algorithms. But after removing s, then 'f ' becomes 4th letter remove that. Then 'a' becomes 4th letter remove that. THe rmaining letter is 'l'. That should be displayed. The number got from my progam can be larger than size of the the string. I can be 11 or 12 or 2.

The algorithm you're talking about is called the Josephus problem.

Sorry. But I'm very poor in Maths and I dunno about logarithm yet. So plz convert it into c++ code. Thank you.

>So plz convert it into c++ code.
I'm sorry, did you just ask me to do your work for you? I've already implemented this algorithm in several different ways, so I won't learn anything from it. Therefore, I'll leave it up to you.

C'mon. I need to complete this before 14th! pleeeeeeeeeeeeeeeeeeeeeeeeeeeeez

Then you'd better get started. You seem to think I give a damn about your deadlines. I might help you with your implementation if you prove that you've actually tried to come up with something. Otherwise I'll just write you off as a freeloading loser who deserves a failing grade.

Boo hoo! The deadline is extended indefinitely! Please someone help!

Just to attract your attention. :cheesy: :lol: :cool: ;)
Here's the problem:
I have this string "flames". Then I get a number from earlier part of myprogram. Let the number be 4. Now 'm' is the 4th character. This should be removed. Then the remaining string is "flaes". Now 'e is the fourth char. This should be removed. Finally only one character remains standing. This character should be displayed.

According to Josephus problem the standing letter for 'flames' would be 'e', unless u r including the nul character u have in ur string. So r u considering 'flames' or 'flames\0' ?

Only 'flames'.

>Please someone help!
Oh, if you insist:

#include <math.h>
#include <stdio.h>

double x(int n, int m, double y)
{
  if (y > n * (m - 1)) return y;
  return x(n, m, ceil(y * m / (m - 1)));
}

int j(int n, int m)
{
  return (int)(m * n - x(n, m, 1) + 1);
}

int main(void)
{
  printf("%d\n", j(41, 3));
  return 0;
}

Thank you!! Thank you!! I'll erect a statue in ur honour!
Only one thing. How do I use this. I have a earlier part of the program. It will return an integer value. This integer value should it be m or n. The no. of characters in 'flames' is 6. Should six be m or n?

I cant believe u r asking for help again after Narue just did the whole thing for u. You know which letter will stand at the end, only thing left for u to do is to display it. May be u should try this Game and then start thinking.

>How do I use this.
You don't. I'm willing to bet that it doesn't meet the guidelines of the assignment, and even if it did, I made sure that the level of ability required to write the code will prove that you aren't the author. But you can try and see if you're willing to get a failing grade and risk being expelled or suspended for cheating. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.