Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yours doesn't count, because you spelled overgeneralize 'incorrectly' :P

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I assume by t.N that you mean t * N.

If that is the case, then this problem is generally unsolveable. If you let N = 4, M = 2, and x = 0, then there are three possible solutions for M^d. If d = 0 and t = 1, then M^d = 1. If d = 1 and t = 1, then M^d = 2. If d = 2 and t = 1, then M^d = 0.

Even for "sufficiently large" values of d and t, this is the case.

[edit]

And even if N is prime, meaning that your numbers have multiplicative inverses, forming the most unpathological case of modular arithmetic possible, M^d still generally has no single solution.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Don't give up brahle! You'll just get used to always making sure you're not overgeneralizing, the way we all did when we slammed into Narue...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

[deleted]

Rashakil Fol 978 Super Senior Demiposter Team Colleague

try this logic...
You know a word isn't a palindrome if it's an odd number of characters.

"dad" is a palindrome.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

All these methods just call procedures that use the comparison operators.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Huh? What are you trying to do here?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

candykane, the first is a warning, which means your code is not technically incorrect there. But you have a variable named 'array1', which you aren't using for anything at all! The compiler, being nice and friendly (in a sarcastic sort of way) is telling you this, since maybe it means you made an error, or just have code that could use some cleaning.

The second error is a syntax error (as the compiler informs you). 'if' branches do not use that sort of syntax in C++.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What are the values of j and k when that code has run?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That code is slow; instead start at the top and count downwards.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Notice that you have a bug where you write,

if(nextchar = '\n')cin.ignore();

I think you meant nextchar == '\n'.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can check convincingly by multiplying them back up.

13 * 22 + 2 = 288.

So your answer is correct.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your function definition says that 'size' is of the same type as the data pointed at by the first parameter. You meant to use int, not TYPE, in declaring the type of the size argument.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

How about I do your homework for you if you do my homework for me. Deal?

:rolleyes:

But actually, no, I'd rather not, because then I'd be wasting a lot of money spent on this education.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Java applets do not have permission to execute arbitrary programs. Do allow such a thing would be an error by the program executing the Java applet. So you need to find a bug in "the" Java interpreter (there are many) that is being used. This is a way of saying "you can't do this."

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Can submarines swim?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It's a simple matter of finding a security hole in the JVM implementation.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you can't figure it out now, get some sleep and think about it tomorrow. And then if you can't figure it out then, think about it the next day. This subject is hard; that's just the nature of the beast, and it can't be helped. Do you think Watson and Crick got the ability to solve the structure of the DNA molecule by asking for answers on all their previous problems?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Write your own ADT that uses a stack and keeps a count of how many elements are in the stack.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You're trying to pass a memory address of a character to a function that, as declared, expects you to pass an individual character. Passing a character by reference is not the same thing as passing a pointer to a character.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I don't see why you would need any help, so how can I know how to help you? You could be a bit more specific about where you're having problems.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In regard to your original code: Could you please explain why it is supposed to work correctly?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you learn Java now, you'll be bored during the Java course.

Learn Scheme. It's a simple language, and is very powerful (in terms of writing useful programs quickly). You'll have a different perspective on things that will make you consider Java and other object oriented languages to be languages of the peons.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I need to find out the execution time of a fragment of code.

You don't need finer resolution timing. If you want to measure the thickness of a piece of paper, would you buy an expensive microscope, or would you measure a stack of 200 pieces of paper and then divide by 200?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

stars

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Huh? Answer to what? (a AND b) OR (NOT b) is not in any of the problems...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You know how to make a simple truth table, right? For example,

a | b | a AND b
---+---+---------
 F | F |    F
 T | F |    F
 T | T |    T
 F | T |    F

If you want to make a truth table for compound statements, just use parts of statements you've made before.

a | b | a AND b | NOT b | (a AND b) OR (NOT b) | ...
---+---+---------+-------+----------------------+------
 F | F |    F    |   T   |          T           | ...
 T | F |    F    |   T   |          T           | ...
 T | T |    T    |   F   |          T           | ...
 F | T |    F    |   F   |          F           | ...

Here, the column (a AND b) OR (NOT b) is derived from the truth and false values from the column a AND b and the column NOT b.

If you want to use 0's and 1's in place of F and T, that's fine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

123456 microseconds equals how many milliseconds?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Design and implement a class hierarchy for any organization, employees.

Why would I want to do that?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You only need to copy one data element and change one link.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm not sure what you mean exactly by "using char instead of string," but if that means something like

for (int i = 0; i < s.size(); ++i) {
    s[i] = toupper(s[i]);
}

then you should be fine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You're declaring it wrong; that'd be vector< vector<char *> >

Rashakil Fol 978 Super Senior Demiposter Team Colleague

No.

If you don't solve this problem yourself, you won't be solve the problem that comes after this one, or the problem that comes after that. You'll might be able to squeak by with a passing grade, but you'll have learned nothing.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

system expects the memory address of an array af characters. Your code is not valid C++ syntax. You could write system("echo 9"); . Or you could use a stringstream to build a string dynamically.

std::ostringstream s("");
int x(9);
s << "echo " << x;
std::system(s.str().c_str());
Rashakil Fol 978 Super Senior Demiposter Team Colleague

I bite them off.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What is the problem you're having?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So, what is the problem you're having?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What is your definition of an 'anti virus'?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Use kode tags :eek: then we mite help u. Next time u ask a question don't just post ur kode and say help me with the missing parts? Pin point an exact problem. Then we mite help u?

If you're going to harass newbies about the way they form their posts, you could at least have the sense of hypocrisy to write yours decently.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The other two statements are openingfiles (one file each) for appending and reading. After they succeed, DIRLOG is the filehandle for writing or reading from the file. Then print DIRLOG "blah.."; writes some text to the end of the file, and close(DIRLOG) closes the file.

The third red statement opens the file for reading. Then @dir_lines = <DIRLOG>; reads the entire file, line-by-line, into @dir_lines. Then DIRLOG is closed.

The arrows, >> and <, indicate whether the file is opened for appending to the end or reading. (A single > is for writing-over.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What operating system are you using?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That looks like an appropriate change, though you don't need to check for execvp returning -1. If it returns, we already know something failed. It returns -1 from historic practice, but the return value has never been standardized. (Or so says the man page on my machine.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Maybe your instructor is using a different definition of pseudocode than is normally used. What is his/her's definition of pseudocode?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You don't actually need getenv. If execvp fails, it returns. That's how you know it fails. But as a side note, you should be using getenv with

char * pathstr = getenv("PATH");

Then pathstr contains the null memory address, or it contains the memory address of a string such as "/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games". That's the output of this miniprogram:

#include <stdlib.h>
#include <stdio.h>

int main(void) {

  char * s = getenv("PATH");

  if (s) {
    printf("%s\n", s);
  }

  return 0;
}

And lastly, I don't get what you mean by putting a line after the execvp line. What would the line contain? An exit(0) statement? I'm a little confused about that.

If execvp returns, you still have two processes running. The parent is wait()ing for the child process to terminate. What do you want your child process to do?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

No.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can use getenv to get the contents of a certain environment value (such as "PATH"). Use man getenv for details.

The reason it seems like it's running another instance of your current shell is because you've forked your shell into a new process. So the program's doing exactly what you've asked it to do. If execvp fails, it simply returns -1. (If it succeeds, it never returns!) Then your child process keeps running until it finds a reason to exit, and then the parent's wait( ) call comes through, and the parent continues.

If you want to handle this, simply include something to handle it after your execvp call. If the call fails, you can write, "Bad command or filename\n", or whatever you want, and then exit() that process. Then the parent's wait() returns, and the parent continues running.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

no its not -- it is still just a pointer, it just contains the address of a c++ class.

In the interest of not confusing the other poster, I'd like to point out that A.D. means 'address of an object [of type string]'.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Look in the directory of your C++ project. In that directory, or in some subdirectory ('Debug' or 'Release'?) should be your exe, once it's been built.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It isn't as important for a New Thread link to appear on the thread pages as it is for a Register link to appear. For all the guests who enter the site from search engines directly to threads, they need to register before they can create a new thread anyways.

No, people want to post a new thread. They're not thinking about registration. If they want to post a new thread, they're not going to be looking for a registration button. The user's goal is to get an answer, not join a community.

Regardless, I have taken your suggestions into consideration and made some changes and added some extra notices for guests. Log out and check it out!

All I saw was one suggestion in a tiny font. It was gray. Inside a rounded rectangle. My eyes skipped over it because it looked like an advertisement. I only saw it and the one at the bottom because you told me to look for them.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm not going to give you any help. I don't think it will help you learn C or C++, which is what I happen to prefer to be doing. Also, I'm not going to make myself an accessory to any illegal activities. This topic should be locked.