Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Lv 55,102 points

He_Who_Shall_Not_Be_Named

Favorite Answers68%
Answers472
  • Online supercomputing?

    I have recently written a program in C++ that computes the best sequence of numbers to use for a given situation. It does this with a brute force technique, which is unfortunately very slow and requires multiple millions of computations. I have run it on my laptop for 15 hours straight and haven't even checked 1 million solutions yet(out of the 34.5 million total). Is there any way that I could pay a fee and have some supercomputer run my program for me, saving me the effort? Can I just upload a .exe file or maybe for security reasons the c++ code and they'll send me the outcome.

    1 AnswerOther - Computers9 years ago
  • Calculus - L'Hopital's rule?

    L'Hopital's rule only applies when a limit is in indeterminate form and when the right hand side either exists or is infinity. Can someone please give an example of a limit that meets the first requirement (is in indeterminate form) but doesn't meet the second? In other words,

    Give an example of a limit where L'Hopitals rule does not apply BUT the limit is in indeterminate form. Thank you!

    1 AnswerMathematics10 years ago
  • C++ fstream - good() vs is_open()?

    Whenever I've used fstream in the past, I've always called both file.good() and file.is_open() every time to check if the file is ok to use. For example:

    while (file.good() && file.is_open()) { /*do stuff...*/ }

    But I was wondering, is this necessary? I know that good() checks for the eofbit, failbit, and badbit flags. Does is_open() do something similar? My main concern here is efficiency. Is file.is_open() redundant or should I check every time? Can my ifstream object randomly close the file because of an error? Thanks.

    3 AnswersProgramming & Design1 decade ago
  • C++ Calculator - Vector SegFault issue?

    I am making a calculator in C++ and am running into an issue. I have built and debugged a way to turn a string containing the equation into a vector of an Element (a custom struct I made to hold the different types of objects). Anyway, the trouble is in a function I use to solve an expression. It uses while loops to go through and simplify the expression one chunk at a time based on the operators (* goes before +, etc.). Here is the loop used to check for multiplication signs:

    OPos = GetFirstOpPos(r, 1);

    while (OPos >= 0 && OPos < r.size())

    {

    te2 = r[OPos-1]; //V1

    te3 = r[OPos+1]; //V2

    te = STD_SolveBinaryOp(r[OPos].op, te2, te3);

    r.erase(r.begin()+OPos-1, r.begin()+OPos+1);

    r[OPos-1] = te; //Replace the second number w/ the number it creates

    OPos = GetNextOpPos(r, 1, (OPos-1));

    }

    P.S.

    r - the vector which stores my formatted equation

    te, te2, and te3 - Elements used to temporarily store the numbers

    OPos - holds the position of the operator (in this case *) that I'm currently working on

    STD_SolveBinaryOp() - solves the simple multiplication problem.

    The error I'm getting is a segfault. When I use the input equation "2*3*4*5" it will work all the way up until the last operation "24*5". It even calculates the result is 120 and prepares it by deleting everything but "5". Then I ask the computer to replace "5" with the answer ("120"). This is when a segfault is thrown.

    I don't get it! I checked the Element object te, its perfectly fine. I just don't understand why it works perfectly for everything except the final multiplication problem. Any ideas, comments, suggestions, anything is much appreaciated. Thanks!

    2 AnswersProgramming & Design1 decade ago
  • 1^2 + 2^2 + 3^3 + ... + (n-1)^2 + n^2 = ?

    I'm trying to figure out an equation that equals this. Kind of like how a hyperfactorial H(n) = 1^2 * 2^2 * ... * n^2 I want to know if there is an addition equivalent? Thanks!

    1 AnswerMathematics1 decade ago
  • Double Factorial's Addition Equivalent?

    I was wondering if there was an easy notation or way of calculating the addition equivalent of a double factorial. For example: 7!! = 7*5*3*1 = 105. I want to know if I can find this FactorialEquivalent(7) = 7+5+3+1 = 16. I found that 7*(7-1)/2 = 7+6+5+4+3+2+1 = 28. Is there a way to modify this to skip every other number like a double factorial?

    Thanks for any help.

    3 AnswersMathematics1 decade ago
  • Dev C++ Linker Error - SAPI?

    I am trying to learn the basics of the Microsoft Speech SDK. I'm building a simple c++ program with Dev C++ that uses the sapi to say "Hello World". Here's my code:

    #include <windows.h>

    #include <cstdlib>

    #include <Servprov.h>

    #include <sapi.h>

    using namespace std;

    int main()

    {

    ISpVoice* Voice = NULL;

    CoInitialize (NULL);

    CoCreateInstance ( CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&Voice );

    Voice -> Speak (L"Hello World", SPF_DEFAULT, NULL );

    system("PAUSE");

    if ( Voice != NULL ) Voice -> Release (); Voice = NULL;

    CoUninitialize ();

    return EXIT_SUCCESS;

    }

    Unfortunately, I keep getting 2 linking errors:

    [Linker error] undefined reference to `IID_ISpVoice'

    [Linker error] undefined reference to `CLSID_SpVoice'

    I did have 4 linker errors before I included libole32.a. Any ideas? Thanks.

    2 AnswersProgramming & Design1 decade ago
  • C++ Help - My Program Is Acting Strangely?

    I am making my own basic compiler. Currently I've added the ability to recognize the declaration of data types (int, bool, etc.) In order to test it, I made the program take in a simple declaration "unsigned short int a;". Now what happens is the line will go into MakeVars() which reads the sentence, tokenizes it, and fills out a struct called StoreVars and returns it. Then another struct called Var extracts the data for the first variable (and there's only 1). This works fine. I then convert the Var struct into a struct called StoreLib. This struct is added to an array where it can be accessed at anytime by the program. After that I retreive the StoreLib object and display the stored data.

    Here's where the problem occurs. When I add the StoreLib object to my array it raises a segmentation fault. But here's the wierd part, when I add the line system("cls"); Sleep(200) or system("pause"); right before this function it works fine! Why? When I tried just adding it to the actual function (which is in a seperate header file) it didn't work, segmentation fault. It only works if I add it to main().

    2 AnswersProgramming & Design1 decade ago
  • C++ Help - C++ Strings?

    I have a function TokenizeWS() which will skip all the whitespace and read the first block of characters seperated by whitespace. Basically if you give it " Hello World!" and position 0 it will return "Hello". Unfortunately, I've found an issue in my code that I don't understand how to fix.

    I use a for loop which copies each character from from string1 to string2 if the character isn't whitespace. If it is, the for loop ends.

    //Skip a few lines

    char TC;

    std::string TempString;

    int* a = new int;

    *a = pos;

    for (; pos<(*SizeOfString); ++pos)

    {

    TC = String[pos];

    if (TC == ' ')

    break;

    else

    TempString[(pos - *a)] += String[pos]; //Problem line

    }

    The problem is TempString doesn't accept the character from String so string is blank. I know that String[pos] = an actual character. I don't know how to even go about this. Any help is appreciated. Thanks!

    2 AnswersProgramming & Design1 decade ago
  • C++ Help - Ifstream Issue?

    I have created a class to handle the input/output of 2 different files for a program. I use an ifstream object and an ofstream object to handle each file. Unfortunately, every time I try to use the ifstream object a segmentation fault is thrown. Here is the function:

    char getline (unsigned int length = 100000, char delim = '\n')

    {

    if (file.good() && file.is_open())

    {

    preline = file.tellg();

    char TS;

    char* TempString;

    *TempString = TS;

    file.getline(TempString, length, delim);

    line = file.tellg();

    return TS;

    }

    else throw ConnectionError;

    }

    My debugger tells me that when I use the second file.tellg() function a segmentation fault occurs and I can't figure out why. Please help, thanks.

    2 AnswersProgramming & Design1 decade ago
  • C++ Help - Ifstream - I don't know what to do?

    I have no idea how 2 go about fixing this, please help. I have a class that handles 1 ifstream object for 1 file & 1 ofstream object for another file. The ofstream works fine but the ifstream is messed up. I use ifstream.getline() and it raises a segmentation fault (not allowed access to file or accesses file in an un-allowed way). Here's my function:

    char getline (unsigned int length = 100000, char delim = '\n')

    {

    if (file.good() && file.is_open())

    {

    preline = file.tellg();

    char* TempString;

    file.getline(TempString, length, delim);

    line = file.tellg();

    return *TempString;

    }

    else throw ConnectionError;

    }

    My debugger says that the segmentation fault is raised right when I use the getline() function. I'm even using the good() & is_open() functions to protect against screw ups. What is going on? Any thoughts?

    2 AnswersProgramming & Design1 decade ago
  • C++ Segfault Error - Out of ideas!?

    I'm working on a c++ code project which requires the ability to read 1 file & write another simultaniously. I have created a class File (not the actual name but who cares) that contains 1 ofstream object & 1 ifstream object. My class handles the classes by ensuring the good() & is_open() functions returns true before any operations occur. The ofstream object works flawlessly when i tested it. The ifstream however keeps raising a segmentation fault when i try 2 read the file. Any ideas? Please & thank you. Here's the function for getting code with the ifstream object:

    char getline (unsigned int length = 100000, char delim = '\n')

    {

    if (file.good() && file.is_open())

    {

    preline = file.tellg();

    char* TempString;

    file.getline(TempString, length, delim);

    line = file.tellg();

    return *TempString;

    }

    else throw ConnectionError;

    }

    1 AnswerProgramming & Design1 decade ago
  • C++ Template Class Operator Overloading? No Clue.?

    I am trying to create a template class called Nullable<T> that allows my C++ code to use nullable types. Unfortunately, i'm having a hard time overloading all my operators. I'm wondering how to overload binary operators like +. Basically, I want this code to work:

    Nullable<int> a = 5; //This line works

    int b = a + 2; //This line doesn't

    Thanks :)

    1 AnswerProgramming & Design1 decade ago
  • C++ char array into int - Help?

    I have a program that reads a file and retrieves 1 line at a time of that file. Then, this is broken up further into char array's that can be processed. If I retrieve a char array of integers how do I combine everything into 1 large integer and save it as an int? For example:

    int Result;

    char[6] Data = "12345";

    //Please fill in the code here so that Result = 12345

    3 AnswersProgramming & Design1 decade ago
  • C++ Command Line Params?

    I'm trying to add a feature to a C++ cli project of mine. I want it to use a switch statment to handle command line parameters. There are 4 of them.

    r - the root number

    S - the starting number

    t - the tolerance level

    s - a bool value

    Each would be followed by a number (except s which would be either si for true or so for false). How would I retreive and save that data? I have this so far but it is error prone.

    if ((argv[1]) == "r"){

    for (int a=2; (argv[a] != "S" || argv[a] != "t" || argv[a] != "r" || (argc-(a+1)) == 0); ++a)

    RNum += (int) (atoi(argv[a]) * pow(10., (double)(argc-(a+1)) ));

    B_RNum = false;}

    else

    if ((argv[1]) == ("S")){

    for (int a=2; (argv[a] != "S" || argv[a] != "t" || argv[a] != "r" || (argc-(a+1)) == 0); ++a)

    SNum += (int) (atoi(argv[a]) * pow(10., (double)(argc-(a+1)) ));

    B_SNum = false;}

    else

    if ((argv[1]) == ("t")){

    for (int a=2; !(isdigit(*argv[a])); ++a)

    TempString[a-1] = *argv[a];

    Tol = atoi(TempString.c_str());

    B_Tol = false;}

    else

    if ((argv[1]) == ("s")){

    if (argv[2] == ("o"))

    {

    SimpOSolve = false;

    B_SOS = false;

    }

    else

    if ((argv[2]) == ("i"))

    {

    SimpOSolve = false;

    B_SOS = true;

    }}

    Please help. Thanks.

    1 AnswerProgramming & Design1 decade ago
  • C++ Segmentation Fault Error?

    I've built a program that finds the nth root of any number for you and I've recently started adding the feature of command line parameters. I googled it and used a if...else thing to handle the different parameters (probably should have just used a switch statment). The data I'm alowing is the root number, the starting number, the tolerance level, and a bool value. Unfortunately, when I go to check a parameter, I get a segmentation fault. Here is what I have so far:

    int main(int argc, const char* argv[])

    {

    bool B_RNum = true;

    bool B_SNum = true;

    bool B_Tol = true;

    bool B_SOS = true;

    int SNum;

    int RNum;

    int Tol;

    string TempString;

    bool SimpOSolve;

    //Handle command line arguments

    //Look for different commands

    if ((*argv[1]) == (*"r")){

    for (int a=2; (argv[a] != "S" || argv[a] != "t" || argv[a] != "r" || (argc-(a+1)) == 0); ++a)

    RNum += (int) (atoi(argv[a]) * pow(10., (double)(argc-(a+1)) ));

    B_RNum = false;}

    else

    if ((*argv[1]) == (*"S")){

    for (int a=2; (argv[a] != "S" || argv[a] != "t" || argv[a] != "r" || (argc-(a+1)) == 0); ++a)

    SNum += (int) (atoi(argv[a]) * pow(10., (double)(argc-(a+1)) ));

    B_SNum = false;}

    else

    if ((*argv[1]) == (*"t")){

    for (int a=2; !(isdigit(*argv[a])); ++a)

    TempString[a-1] = *argv[a];

    Tol = atoi(TempString.c_str());

    B_Tol = false;}

    else

    if ((*argv[1]) == (*"s")){

    if (*argv[2] == *"o")

    {

    SimpOSolve = false;

    B_SOS = false;

    }

    else

    if ((*argv[2]) == (*"i"))

    {

    SimpOSolve = false;

    B_SOS = true;

    }}

    Where am I going wrong? Thanks.

    3 AnswersProgramming & Design1 decade ago
  • C++ 256 ASCII Chars in Dev C++?

    Hi. I'm trying to create an array of 256 unique ascii characters in Dev C++. I have gathered 213 from across the web and am now struggling to find another 43. I've already used the standard ones; 0-9, a-z, A-Z, all the ones on a keyboard and several html ones. Is there a quick way to find them? If there aren't enough ascii characters out there, are there other 1 symbol characters that totals 256 or more? Thanks for any advice you can give me.

    P.S. Some characters like ♥ show up as ? in Dev C++.

    4 AnswersProgramming & Design1 decade ago
  • C++ Base class - Derived class Help?

    Is it possible to replace a base class with a more specific derived class by setting them equal to each other? For example:

    class A {//Stuff};

    class B : A {//More stuff};

    A c;

    B d;

    c = d; //Now c has become d (class B with all the data of d in it)

    Is that possible? Is there another way to do the same thing? Thanks.

    1 AnswerProgramming & Design1 decade ago
  • C++ Class Hierarchy Function Help?

    I am building a series of header files for a program. One header file creates a hierarchy of classes like this:

    C_Object<> --> C_Int -->C_H

    --> C_Bool --> C_P

    etc. My first base class is a template. The second base classes I created with typedef. (Ex. typedef C_Object<int> C_Int) Finally the derived classes are a list of specific classes.

    Ok, down to business. I have a function that compares a char to a char in each derived class (3rd) and returns the corresponding class. Unfortunately though, I have a bunch of classes with different variables (C_Object<int> and C_Object<bool>). In another function that calls this one I need to know which base class (2nd) the class has. How?

    P.S. Sorry for the long explanation.

    1 AnswerProgramming & Design1 decade ago
  • Math Question - Almost Infinite Pattern?

    If I have a number n, how do I represent this in mathematical terms?

    y = n*(n-1)*(n-2)*(n-3)... until n = 2

    Im only in Geometry so please go easy on the math terms.

    I appreciate any help you can give me.

    P.S. This is not math homework.

    2 AnswersMathematics1 decade ago