Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing

This Question is Closed

Jas11Best ResponseYou've already chosen the best response.0
#include <iostream> #include<cmath> using namespace std; //global constants const int MAX_PAIRS=10; //data types struct point { double x, y, distance; }; enum pointType {valuex, valuey, valued}; //functions void readData(point[]); void sortData(point[],pointType); void printData(point[]); int main() { pointType i; point pointList[MAX_PAIRS]; readData(pointList); for(i=valuex;i<=valued;i=pointType(i+1)) { sortData(pointList,i); if(i==valuex) cout<<"this is soorted by x in ascending order"<<endl; else if(i==valuey) cout<<"this is sorted by y in descending order"<<endl; else cout<<"this is the distance by ascending order"<<endl; printData(pointList); } return 0; } void readData(point pointList[MAX_PAIRS]) { int i; for (i=0;i<=MAX_PAIRS1;i++) { cout <<"please enter the x and y for the pairs "<<i+1<<endl; cin>>pointList[i].x>>pointList[i].y; pointList[i].distance=sqrt(pow(pointList[i].x,2)+pow(pointList[i].y,2)); } } void sortData(point pointList[MAX_PAIRS],pointType whichValue) { int i,last; point temp; bool outOfOrder; for(last=MAX_PAIRS1;last>=0;last) for(i=0;i<=last1;i++) { switch(whichValue)//which field am I sorting by? { case valuex: outOfOrder=pointList[i].x>pointList[i+1].x; break; case valuey: outOfOrder=pointList[i].y<pointList[i+1].y; break; case valued: outOfOrder=pointList[i].distance>pointList[i+1].distance; break; } if(outOfOrder) { temp=pointList[i]; pointList[i]=pointList[i+1]; pointList[i+1]=temp; } } } void printData(point pointList[MAX_PAIRS]) { int i; for (i=0;i<=MAX_PAIRS1;i++) { cout<<pointList[i].x<<", "<<pointList[i].y <<", "<<pointList[i].distance<<endl; } cout<<endl; }
 one year ago

rohitranjan1994Best ResponseYou've already chosen the best response.0
which function.....
 one year ago

ADGENIUSBest ResponseYou've already chosen the best response.0
there are more than one functions in this program. Please specify any particular function whose operation you want to know.
 one year ago

Jas11Best ResponseYou've already chosen the best response.0
@rohitranjan1994 @ADGENIUS I wanted to know what all three functions did
 one year ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.