0

hi every one;
i saw this question and im trying to solve it.\
baseically i have to matrix's which each element is afraction
so i must declare a class that has in the privet to float members numerator and denomnator
and in the public i have constructer function to inilize the arrays
and function subtract ,multiply,and add,.
and im asked to add the 2 matrix and subtract them...

sample input:
3/2 4/5 1/4
4/9 7/9 2/4
and the other matrix has the same format...
note that each function has parameter (2 fractions)

i just need som idea how to solve this problem??
i now the basic but when it comes to functions i feel confused and
i dont know how to complet..

thanks in advance.:)

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by moonL!ght
0

Sounds like you need to make a "Fraction" class and then make an array (I'd recommend a std::vector) of Fraction objects.

std::vector<Fraction> fractions;

I hope this gets you started - once you get some code written post it here and I'm sure someone can help you with any difficulties.

Dave

0

unfortionatly i didnt take vectors yet at collge im still abiggener
im planing to studey them on summer:)
thats why i feel confused ...
is there any other ideas that it can push me forward..

moonl!ght

0

hi there,
since that time i was tring and i figured that there was a mistak done by the writer of the question so this is apart of the code

int siz1,siz2;

fraction::fraction()
{
	//decleartion and opining files
	fstream indata;
	indata.open("matrixes.txt");
	if(indata.fail())
	{
		cout <<"cannot open the file \n";
		exit(1);
	}
	cout<<"hi"<<endl;
	indata>>siz1>>siz2;
	cout<<"hi"<<endl;
	for(int x=0;x>siz1;x++)
	{

		for(int y=0;y>siz2;y++)
		{
			indata>>MTRX1[x][y].num>>MTRX1[x][y].div>>MTRX1[x][y].denum;
			cout<< MTRX1[x][y].num<<MTRX1[x][y].div<< MTRX1[x][y].denum<<"    ";}
	cout <<endl;
	}

and the problem is that the compiler dosent go thruogh the loop !!
dose any one now why?

0

thanks very much ...sometimes you cannot recognise the mistacke by your self you need a thired eye..:) thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.