CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: math8

Page 1 of 2 1 2

Search: Search took 0.04 seconds.

  1. Re: Creating a Matrix given arrays of the same dimensions

    I think I can use an ArrayList and an 'enhanced for loop' to loop through all its entries. I was hoping there was a way to refer to the 'argument's number' of a method, but apparently not.
  2. Re: Creating a Matrix given arrays of the same dimensions

    My question is, is there a way for the method to loop using each of its arguments one by one?
    For instance, in the code below, is there a way to write the line "M[i] = argi;" in a correct way so...
  3. Re: Creating a Matrix given arrays of the same dimensions

    I am not trying to change the number of arguments the method has, I am just wondering, just like you can find the number of entries an array arr has by typing arr.length, is there a way to find the...
  4. Re: Creating a Matrix given arrays of the same dimensions

    hmmm, by thinking about this a little bit more, I think this should work:


    double[][] M = new double[2][a.length];
    M[0]=a;
    M[1]=b;

    But still, let say, instead of two arrays, I have two...
  5. Creating a Matrix given arrays of the same dimensions

    say I have two int arrays of length 3 (ex: a = [ 1 2 3] and b = [4 5 6])
    I would like a method that returns the 2x3 Matrix:

    M =

    1 2 3
    4 5 6.

    I have tried using
  6. Replies
    11
    Views
    2,867

    Re: virtual destructor

    Thanks, that makes sense
  7. Replies
    11
    Views
    2,867

    virtual destructor

    I know a virtual function is a member function of a class whose functionality can be overridden in its derived class.

    If you have a virtual statement, do you need to assign your destructor as a...
  8. Re: Coin/Money change code doesn't give exact change!

    alright, but aside from that, what is wrong with what I wrote before?
  9. Re: Coin/Money change code doesn't give exact change!

    hmmm, let see. Maybe something like:



    for(int i=0; i<=n/10;i++)
    {
    if((n-(i*10))%25 ==0)
    {
    x=i; //number of 10's
    z=(n-(i*10))/25 ; //number...
  10. Re: Coin/Money change code doesn't give exact change!

    I wasn't sure what you meant by "evenly". But first of, intuitively, for this problem to make sense , the "cents part" n must be either 0 or >=10 and at least n must be a multiple of 5 .
    So the only...
  11. Re: Coin/Money change code doesn't give exact change!

    when you say "evenly" do you mean by solving: 25x+10x=y, where y is the cents value?
  12. Replies
    2
    Views
    1,318

    stopping an infinite loop.

    The code below gives me the maximum odd number and the minimum even number of a list of numbers that the user type. However, for the loop to stop the user needs to type 1000. Is there a better way...
  13. Re: Coin/Money change code doesn't give exact change!

    I think the code is performing how it should, I think the problem is behind the logic (I guess that's the design). I am hoping to get 23 10's, one 5, two 1's ,2 quarters and 3 dimes.

    The logic...
  14. Re: Coin/Money change code doesn't give exact change!

    yeah, it should, my bad. Unfortunately, it doesn't.
  15. Coin/Money change code doesn't give exact change!

    My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it...
  16. Re: calling another function within a function isnot working

    Never mind! found the error!! I needed to change the () into a [] in eKey(i), because eKey is not a function .
  17. calling another function within a function isnot working

    I have two functions bool check_key(string cKey, string eKey) and bool check_digit(char digit1, char digit2), and I have declared both of them globally (is this the right terminology?) right after...
  18. Replies
    2
    Views
    1,050

    Re: Adding two objects of class "Matrix"

    great, thanks!
  19. Replies
    2
    Views
    1,050

    Adding two objects of class "Matrix"

    I am trying to add matrices a and b. I am getting an error in the "add" function, probably because I have m[i] in it, and m is not an array. What is the correct way of writing the "add" member...
  20. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    hmmm, I rearranged some things around, and this is what I came up with.


    #include<iostream>
    #include<fstream>

    using namespace std;
    ifstream file1;
    ofstream file2;
    void menu0();
  21. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    Thanks, I will keep that in mind.

    However, I am running into this new problem: In the void Frequency function that I had , besides calculating the frequency, it was also calculating the number of...
  22. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    Alright, I see what you are saying. But technically speaking, in my method, I write the same amount of text "cout<< / file2<<" - wise (except that I have 2 different but similar functions to call as...
  23. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    Could you give me an example of a function of type double, float,or char that can return some text both for the screen and for the ouput file. I tried earlier, and I couldn't make it work, that's why...
  24. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    I just figured out what was wrong.

    I cannot use the same function Frequency when printing out on the output file. I had to create a copy of the Frequency function and in the new one, I replaced...
  25. Replies
    16
    Views
    2,760

    Re: I cannot print on an output file

    Thanks, I can see it is an error. If I wanted to get the results of void Frequency(alphabet[p], num, a) on the screen, I would just write
    Frequency(alphabet[p], num, a) ; (with no cout<<). However,...
Results 1 to 25 of 36
Page 1 of 2 1 2





Click Here to Expand Forum to Full Width

Featured