Define a class to represent a COMPLEX NUMBER. Now, in your class, Declare member data to represent the following: o Real value of the complex number o Imaginary value of the complex number Define following member functions to: o set the value of a complex number object o get real value of a complex number object o get imaginary value of a complex number object o display a complex number in the form of “x + y i”, where x is the real value and y is the imaginary value ----------------------------------------------------------------------------------------------------------------------------------------------------------------- In your main(), Get n (how many complex numbers) from user and allocate necessary memory to a pointer called ptr to store n complex numbers. Call a global function with ptr & n as parameter: populateAndDisplayComplexNumbers(ptr,n); Call a global function to print the complex numbers in ascending order based on their real values & then by imaginary values: displayInSortedSequence(ptr,n); Find sum of all complex numbers, and difference between first and last complex no of your array-by-pointer: ComplexNo sum, difference; sum = getSumAndSetDifferenceOfFirstAndLastNos(ptr,n,difference); sum.display(); difference.display();
Aucun commentaire:
Enregistrer un commentaire