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

# Search:

Type: Posts; User: math8

Page 1 of 2 1

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

by math8
Replies
7
Views
6,816

### 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. ## Thread: Creating a Matrix given arrays of the same dimensions

by math8
Replies
7
Views
6,816

### 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. ## Thread: Creating a Matrix given arrays of the same dimensions

by math8
Replies
7
Views
6,816

### 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. ## Thread: Creating a Matrix given arrays of the same dimensions

by math8
Replies
7
Views
6,816

### Re: Creating a Matrix given arrays of the same dimensions

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. ## Thread: Creating a Matrix given arrays of the same dimensions

by math8
Replies
7
Views
6,816

### 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

by math8
Replies
11
Views
1,654

### Re: virtual destructor

Thanks, that makes sense

by math8
Replies
11
Views
1,654

### 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. ## Thread: Coin/Money change code doesn't give exact change!

by math8
Replies
20
Views
2,377

### Re: Coin/Money change code doesn't give exact change!

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

by math8
Replies
20
Views
2,377

### 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. ## Thread: Coin/Money change code doesn't give exact change!

by math8
Replies
20
Views
2,377

### 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. ## Thread: Coin/Money change code doesn't give exact change!

by math8
Replies
20
Views
2,377

### 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. ## Thread: stopping an infinite loop.

by math8
Replies
2
Views
735

### 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. ## Thread: Coin/Money change code doesn't give exact change!

by math8
Replies
20
Views
2,377

### 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. ## Thread: Coin/Money change code doesn't give exact change!

by math8
Replies
20
Views
2,377

### Re: Coin/Money change code doesn't give exact change!

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

by math8
Replies
20
Views
2,377

### 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. ## Thread: calling another function within a function isnot working

by math8
Replies
2
Views
658

### 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. ## Thread: calling another function within a function isnot working

by math8
Replies
2
Views
658

### 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...

by math8
Replies
2
Views
563

### Re: Adding two objects of class "Matrix"

great, thanks!

by math8
Replies
2
Views
563

### 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. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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;
21. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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. ## Thread: I cannot print on an output file

by math8
Replies
16
Views
1,302

### 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