0 like 0 dislike
2.2k views
Show more...
[Exercise] Coding (C) - asked in C++
ID: 24587 - Available when: Unlimited - Due to: Unlimited
| 2.2k views
0 0
Called for Help

26 Answers

0 like 0 dislike
Hidden content!
#include ** *** * * ** *

#include *** * *** * *



using namespace std;



class Point{
*** ***** * *
** * ****** ******* * * * ** xpos, double ypos);
* * * * * * * ** **** ** *
*** ** * **** *** ** * *** ** other);
* * * ** ** * *** reflect();
* *** * **** ** ****
* ** * * * * * * * x;
** ** * ** ** * *** y;

};


** * ****** xpos, double ypos)

{
* **** *** ** ***** * = xpos;
* ** ** **** *** * *** * = ypos;

}



string * * *

{
* ** * * * * ** * * *** re;
** * * ** *** * ** * ** * * * * * * * x * ** * ** ", " * *** * ** y * *** ** * * * * ** *
***** *** * ** **** ******** re.str();

}



bool ** * *** * * ** other)

{
*** * * * *** **** == other.x ****** ** y == other.y)
* ** *** ** *** **** *** * * * * ** *** * true;
*** ** *** * * *** **
* **** * ***** * * * ** * * ***** *** * * ***** false;

}



void * *

{
** * * * * ** ** *** * * temp = x;
**** ** * ****** * ** * * = y;
* ********* * ****** ** * = temp;

}



int main()

{
** *** * ** * ** * ** * ** ax, ay, bx, by;


******* ******* * * * ** ** * ****** * ax *** * ay * * ** bx * ** * by;
* ** * * *** * * * * * *** A(ax, ay);
* * ** *** * * * * ** B(bx, by);


* * * *** * ** ** ** ** * ** *** * * ** ** *** endl;
* ** * * ** * ** **
** * *** * *** ** ** * * * * * * * *** * * ****** **** * *** "A equal B" * * * **** endl;
** *** * ******** * ** *
* * *** *** * *** ** **** * **** ** ** *** **** "A not equal **** * * ** * ** endl;


*** *** * * * ** ** ** *
* ** * * * ******* ** **** * ** *** *** *** * ** endl;


* * ** * * *** ** **** 0;

}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include * * ****

#include *** ** * **



using namespace std;



class Point{
** * **** *
* ** ** *** * * **** *** ** *** xpos, double ypos);
** ** ****** *** *** ***** ** * * * * *
***** * ** * * * ** *** * other);
*** *** * ** ** ** *** * reflect();
* *** * *
** ** * * * ** ** x;
* ** * * ** * *** *** y;

};


**** * ***** xpos, double ypos)

{
* * * * ** * * = xpos;
**** * ** ***** *** = ypos;

}



string * *** ** * ****

{
** * ******** ***** * * * ** * ** re;
* * * * * * * * *** * ***** * **** *** * * x * **** ", " ** * * y *** ** * * * * ***** *
* *** ** ** *** ***** re.str();

}



bool *** ** other)

{
***** *** * * * *** == other.x * *** ***** y == other.y)
* ** * * * * * * * ** **** * * * * *** ** * *** true;
*** ** * ***** ** *
** * ** **** ** ** ** * * ** **** ** ** * * * ******* false;

}



void *** * *

{
**** ** ** *** * *** * temp = x;
***** * *** * ** ** * = y;
* * * ** ** ***** * = temp;

}



int main()

{
** * * * ** ** ** * *** * * *** ax, ay, bx, by;


* **** * * * * * * * *** ***** * ax *** ** ** ay * *** * bx ** * by;
* * * * ** **** * * ** * * ** A(ax, ay);
***** * **** ** * ** B(bx, by);


* * * * ***** * * * *** * *** ** * * * endl;
* * * ** * ** * *** *** ***
* ***** ** *** ** * * *** * * ** * * * * *** ** *** "A equal B" ***** * ** endl;
** * * * * *** * ** * ***
*** * * ** * ****** ** *** * *** ** ** * ** ** * ** * "A not equal * * * * *** *** endl;


** ***** ****** * * ******* *****
*** * *** ** ** * * * * ** ** ** * * *** * * *** ** endl;


* *** * * * * *** * ** *** ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include ** * ** *

#include ** * ** *



using namespace std;



class Point{
******* * * ***** **
***** ** * ** * * * xpos, double ypos);
* ** * * ***** * **** * * *
****** * ** ** * **** * *** *** * other);
* * *** ** **** * * * ** reflect();
***** * ** * *******
* * **** ****** * ** *** x;
**** * * ** ** * *** **** y;

};


* ** * * * xpos, double ypos)

{
* ******** ** *** * *** = xpos;
** ** * * ** * = ypos;

}



string * ***** *

{
* * ****** * *** * * * * * *** re;
* * ** ** ** * * ** *** *** *** *** * * * **** * x ** ", " ****** y ** * * * *
** *** *** *** ** ** ** * re.str();

}



bool ** ** * * * * other)

{
**** *** ** *** * == other.x ** * y == other.y)
** * ** **** *** * ** *** ** * * * **** * * true;
*** ** *** * * * ** *
** ****** ** ** * * *** ********* * * * * * ** *** false;

}



void ** * * **

{
**** ** * * ********** ** temp = x;
** * * *** * * * * *** * = y;
* * * ** ** * * = temp;

}



int main()

{
** * * * * * *** ax, ay, bx, by;


* ** *** ***** * ** *** * ax * * ** * * ay ** * ** bx * * ** by;
** * * ** * * ** *** A(ax, ay);
**** *** * *********** * B(bx, by);


*** * * * *** ** ** **** ***** **** * * ** * * * endl;
* ** * * * *** ** *** ***** * ** *
* * * ** *** * **** ****** ** * * * * *** ** *** * * ** "A equal B" * * * endl;
**** ** * ***** * *
* ** * *** *** * ** ***** *** * * ** ** * *** *** * * ** * * * "A not equal *** * * ** * *** endl;


** * * ***** ** * * **
* ***** ** * * * ** * * *** ** ** ** * * endl;


** * ** ** * * * * * ** ****** 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include *** * * ***

#include * * ** *** *** *



using namespace std;



class Point{
*** **** *
** *** * ** * * **** **** * xpos, double ypos);
*** ** * * * * *** * * ** **
* **** ***** * * ** *** * other);
* * * ****** * *** ** * * * reflect();
** ** *** *
* * ** ** *** ** x;
**** **** **** * ** * y;

};


** * * xpos, double ypos)

{
**** *** * * * ** **** = xpos;
****** * * ** **** = ypos;

}



string ** * *

{
** *** ** * **** ** **** *** * re;
** *** * ***** *** ** * * * * * * ** * ** * x * ** * * ", " * ** y *** ** * ** * ** * * *
* * * * * * * ** ** **** re.str();

}



bool * * **** other)

{
* * * * * * *** == other.x * *** * ** y == other.y)
** ** * **** * * * *** *** ** *** ** * ****** *** true;
** * * * ***** *
** * * *** * ** * **** * **** * * * false;

}



void * * *

{
* ** *** ** *** * * *** * temp = x;
*** ** * * * ** ****** ** = y;
*** *** * * ** * ** * = temp;

}



int main()

{
** * * ** * * **** * * ** * ax, ay, bx, by;


** * * ** *** * * ** * ** *** ax * * * * ay ** bx ** ** by;
* * ********* **** ** * * A(ax, ay);
** *** * * ******* *** ** B(bx, by);


*** * * * * ** * ***** * * * *** * * ***** * endl;
** * * ** * ** * ** * ** * ****
* ** ****** * ** *** **** ** * * * ******** * ** * ** "A equal B" ** *** * endl;
* *** ** * ** * * * *
** * **** ** *** * ** * **** * * ***** *** ** * **** * * "A not equal *** ** ** ** endl;


* * * **** *** ** * *** *
** ** ** * * *** * * *** ** ** * ** * * * *** *** * * * endl;


* *** ** ** * ** * **** 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
* * ** * **** *



using namespace std;



class Point {
** * * ** * **** *
******** * ** ** * *** * ** ** ** * * xpos, double ypos);

** ** ** * *** * **** ** * * ** * * ** * to_string();
** ** * * *** ** * * * * * * *** * ** * equal_to(Point other);
* ** ** * * * ******** *** **** * * reflect();
** * ** *** ** *****
** ** * ** **** **** * *** **** * x;
* * ** ** ** ** *** * * * ** *** ** * y;

};


* * * *** xpos, double ypos){
* *** * * * * *** * = xpos;
* * * * ** * ****** = ypos;

}



string * *** *
** * * * * ** ********* **** * * *** ** **** *** x << ", " << y << * ** * *

}



bool ** * * *** * other){
*** * **** ******* ** * * == other.x * *** * * y == other.y){
**** * * **** * * * * ** *** *** true;
** *** ****** ***** *
** ** * * ** ******* * *
* **** * *** * * **** ****** * ***** *** ** * false;
** * * ****** * **

}



void * * ** *
*** * ** * * * * * * * temp;
* ** ***** * * ** * * * * = x;
* * *** ** ** * * = y;
* *** * ** * ***** * = temp; * *** * ** ****

}
* * * * ** * ** * ** * *

int main(){
* ************* * *** * ***** ** ax,ay,bx,by;
* * * ** * *** *** *** ** * * ** * ** * ** *** *** * **
** *** * * * ***** * ** ** A(ax,ay);
*** ****** * * * * *** * B(bx,by);
** ** ** ** **** ** * **** * * ** * ** * ** ** * ax * *** ** ", " * * *** ay * ** ** ** * ***** * * * ** endl;
*** **** *** ** ** ** (A.equal_to(B)) * * * * *** **** **** equal ** * **** ** *
* *** * * * *** *** * * ** * * * ** * ** not equal * **** * **
* * * * *** *** ** * * ** * *
* * * * * ** ** ** ***** *** * ** * * ** * ** * * ay * **** * ** ", " << ax * ** * * ** * * * ** * ** * ** endl;
* **** * *** * * * * *** ** 0;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
#include * ** * * *

#include <string>

#include <sstream>

using namespace std;



class Point {

public:
* * * ** ** *** ** * * operation 1. a constructor with given x and y coordinates
***** * ** * * * ***** * * xpos, double ypos){
** * *** * * ** ** * * * *** * * ** ** * * * * = xpos;
*** ** * ****** **** * * * *** * * * * * = ypos;
** * * * ** **** *
** * ** ** ** *** * operation 2. get a string representation
* ** ** * *** **** * *** * to_string(){
** ** * ** * ** * ** * * **** *** ** ***** ** ss; string s1; string * ** ** * *
** ******** ***** * *** * *** ****** *** * * ** * << x;
****** * * * ** * * * ** ** * * ** >> s1;
*** ***** **** ** *** ** * *** **** ** * * *** += s1;
*** ** * * *** * ** * * * * * * * * += ", ";
* ** * * *** * ** * ** ***** * * * * ** *** ** **
* ** * *** ** * * **** * ******* * ** * *
* * *** * * * ***** *** *** << y;
*** ** ********** *** * ** * ** *** ** >> s1;
* ***** ** ** ** ** * * *** * ** **** * += s1;
* * * * * * ** * * * ** * ** *** * * * * += ")";
***** * **** * ** * * * * * * * * ** **** s2;
** * * * *** * *
** * ***** ***** ** * *** operation 3. check if two points have the same location
*** * * * *** * * equal_to(Point other){
** ** ** * *** *** ** ** ****** * * * ** (x == other.x && y == other.y)
*** * * *** * **** * ** * * *** * * * * *** * * * * ** ** * * * ** 1;
* **** * * ** **** ** * ********* **** *
** * *** * ** * * **** ** * ** * ** * * * * * ** * ** ** * ** * ***** 0;
** **** ***** * *** * *
* **** ** ** ** * ** * * operation 4. transform the point by swapping its coordinates
* *** * **** * ** ** reflect(){
* * ** * * * * *** ** ** * ** * * ** * ** *** * *** temp;
** * * ** ** **** **** ** * **** ** = x;
* * ** *** **** *** * *** * * *** ** * * = y;
**** ** * * * * ** ** * ** ** * = temp;
* ** * ** *** * ** *

private:
*** ***** *** ** * * *** * * x;
* *** ** * ** * ** ***** *** y;

};



int main() {
*** ** * * * ** ax,ay,bx,by;
*** ** * ** ** *** ** ** ** ** * * * *** * * *** *** *** **
** ** ** *** *** * * A(ax,ay);
* ** * **** *** * ****** * * B(bx,by);
** ** * *** *********** * * * * **** ********** * * * * * * ***
**** **** * * * ***** (A.equal_to(B)) ** * ** * * * equal * * * ** * * **
* ** ** * * * * * * * * * **** * * not equal ** ** *** **** *** * *
** * *** * * ** * ** ** ** * **
* ****** ********* * ** * * *** ** *** * ***** * ** * *


* * * *** ** * * 0;



}
answered by (-368 points)
0 like 0 dislike
Hidden content!
* **** * * *** * *
* * * * * *

using * ** std;



class Point {
* ** * *** * * *** * * **
* ******** ** *** * **** *** *** * **** ******* **** xpos, double ypos);

* ** ** ** ***** **** * * *** * * * ** * * *
*** * * *** ******** * *** **** * * * other);
** *** ***** ** * ** **** * *** * *
* ** ** ** * * * *
** * ** * * * ** ** ** ** ** x;
*** ** ** ** * * * *** * ***** * ** * y;

};


* * *** xpos, double ypos){
* ** * * x = xpos;
** * * * y = ypos;

}



string * *** * * * *
* **** * * cout **** *** **** ** * * * *** * x *** ** * **** ** * ** ** ** y *** * *** * ** ***

}



bool * * * * * other){
*** * ** * if(x == other.x * * * * * y == other.y){
*** * ** **** ** * **** *** return true;
*** ** * }
* *** ** *** * else{
* * * * *** * ** * * ** return false;
* * *** * }

}



void *** * *
* ** **** int temp;
* * * * * temp = x;
* ** ** * * x = y;
* ** * * * * y = * * * * *

}
**** *****

int main(){
* *** * * * double * **
** * ** ** ** * ** * ***** ** * **** * *** *
** ***** Point A(ax,ay);
* * ** * Point *
* ** * ** cout ** * ** ** * * ** ** * ax * * ** **** * **** * * * ay * * * ** * *** * ** * *** ** * endl;
** ** ** * * * if * * ** **** **** ****** *** ** equal * * * * ** * *
***** ***** else * *** ** *** * * * not equal * ************* ** * **
* * * * * ***
** * * ** * cout * * * ** * * ** * * * * * ** ay * **** * **** * * * * *** ax * *** * * * * ** * * *** * *** endl;
* * ** *** return 0;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
* ** ******** * **
** * ** ** ******

using ** std;



class Point {
*** ****** ** ** * *
*** * * * *** ** *** * * *** * * * xpos, double ypos);

** ** * ***** ******* *** * *****
**** * **** ** **** * * * ****** *** **** * * other);
** ****** * ** * ***** * * ** ** * ** ***
** * * *** **
* * * * * * ** * * * * * * ** *** * x;
**** * ** ** ** ** * ******* ** * y;

};


* * * ** ** xpos, double ypos){
* ** ** * **** x = xpos;
*** y = ypos;

}



string **** *
* * * * * cout * * ** *** **** * * ** * x ** * ** * * * **** ** ** * ** y * * * * *** * * **** * ** *

}



bool ** ***** other){
* * * ** if(x == other.x ** * * y == other.y){
** ** * * * * *** * * * * return true;
* ** * }
****** ** ** else{
* * ** * ** * ** return false;
** ** **** }

}



void * * ** * ***
* *** * * * int temp;
***** * * * * temp = x;
** **** *** x = y;
* **** * * * y = ***** **** *

}
*** ** * *

int main(){
** *** * *** double * * *
* *** * * * * ** * ** * *** * ** ** ** * ** ***** * **
* * * *** * * Point A(ax,ay);
* * * ** * Point *
* **** * * * cout ** ** * * * ** ***** * ** ax *** *** * *** *** * ** * ** * ay * * * ** **** ** * * * * * endl;
* * *** if * ** * * * ** * ** **** * * * equal *** * **** **
** * * *** else * * ** * not equal ** * *** ****
* * ** ** **
** * * * * * *** cout ** ***** * * * * * * * ** * *** ax ** * * * ** ** * * * * ay *** * * * * *** * *** endl;
* ** * ** return 0;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
#include <string> ******** ** *** ******** ** ** std::string

#include <iostream>     // std::cout

#include <sstream> ** * * *** *** ** * * * * * std::stringstream

using namespace std;



class Point {

   public:
* * *** **** ** * * ** ** * **** **** * operation 1. a constructor with given x and y coordinates
*** * * * * *** * * * ***** * **** xpos, double ypos)
* *** * ******* ** *** ***** ** ** ******
** * * * * * * *** ****** * * ** ** ** *** *** * ***
* ** * ** * * **** * ** **** ** *
* * * **** * * * * ** * **** * * ** ** *
* * ***** * *** ** ** * ** ** * ** operation 2. get a string representation
*** ** * * * * * * ******** ** ** print()
** ** ** ****** * * **** ***** ** *
** * * * * * ***** ****** **** ** * ** * * **** * ** * * ss;
* **** *** * * ** ** ****** ** * ** * * ** ** * *** ** *** * * ** ** ** *** * * *** **** * * ** ** ** * * * * * * ** ** **
*** * * ******* ** ** ***** ** * * ** * * * *** ** * ** * ** convert_str;
** *** ** **** *** ** **** * * ** * *** * * * * * *** ** ** = ss.str();
* ** *** *** **** ** * ** *** * * ****** ** * ** *** * *** ** * convert_str;
*** ***** ****** ** ** * * **
*** **** * * * ** ** * * ***** operation 3. check if two points have the same location
* * ** * *** ** * ** **** ** **** equal_to(Point other)
* ** * *** * * **** *** *** * ***
* * * ****** ** *** * *** * *** * *** * * *** * ** ** *
**** ** ** * ** * **** * ** ** ** * ** * *** ** * *** * ** true;
*** *** ** ****** ** * ****** ** ** ** * ** ***** * ** * * **
*** * * ** * ** * * * **** * *** * * ** * * ** * ***** ** *** ** *** ** false;
* * * **** * * **** *** *** * * * *
* *** *** *** * * * * * * operation 4. transform the point by swapping its coordinates
** * * ** * **** *** ** * *** reflect()
*** * **** * * *** * * * * ** **
** **** * ** * * * * *** * *** ** * * ** ** ***** * ** swap;
* * ** *** * ** * * ***** * ** * **** ** ** * **** ***
* * ** ** *** * * ** * ***** ** ** * ***** * ***** * *
** **** * ** * * ** **** *** ** * ** * * * * *** * ** *** ** ****
* *** ** *** **

   private:
* ** * * **** * * * * **** ** x;
* * *** * * **** **** * * *** *** ** * y;

};





int main(){
** ****** * * * * * * ** ** ax,ay,bx,by;
* * * ** ****** ** * * *** * *** ******** ** * ** ** *
* * * ** * **** * ***** ** A(ax,ay);
*** ** * **** * ***** B(bx,by);
* *** **** *** * ******* *** ***** * * ** *
** * * *** ** * (A.equal_to(B)) cout<<"A equal B"<<endl;
* * *** * *** cout<<"A not equal B"<<endl;
* ** * * * * *** * ***
***** * ** ** ** ** ** * * * * * *
* * * ** ******* ** ***** 0;

}
answered by (-412 points)
0 like 0 dislike
Hidden content!
* * * * **
* ** * ** * ****
**** * * * * ****
* * * * * * *** **



using namespace std;



class Point {
* * *** ****** *
* ** * ** ** ***** *** * operation 1. a constructor with given x and y coordinates
** * *** * **** * **** ** * ** ** xpos, double ypos);

* * * * * * ** * * * ******* * * ** operation 2. get a string representation
* * * ******** * ** **** **** ** *** * * to_string();
** **** ** * * ** * *** * * operation 3. check if two points have the same location
* *** ** * * **** ** * ** ** * equal_to(Point other);
* **** *** *** * ** *** *** * operation 4. transform the point by swapping its coordinates
* ** ** * * * * **** * ** ** **** *** * reflect();
** ** * * * ** **
* **** *** * * * * *** * * * * * x;
** ************ * ** * **** * ***** y;

};


*** **** *** * xpos, double ypos)

{
*** *** *** **** ** ** *
** *** * ** ** * ** * **

}



string **** ** *

{ * * ****
** * * ** * ** * * *** xs,ys,strings;
* * * ** ***** **** strs, str;
* ******** * * * * * * **
* * ** * *** **** * ** ** * * ** *
*** * * *** * * *** *
* * * * *** **** * ** * ****** * ***
* * ** ***** * * * * * ******** ** ** * ** * * * ****
** ** ** * * * * ** ** * strings;

}
* ** **** *** **** *

bool * * * * other)

{
* * ** ** * * ** * ********** * * **** * y==other.y)return true;
** * * * * *** *** * ** return false;

}



void Point::reflect()

{
* *** * * * * * *** **** ** xx;
* **** * ** * ** * *
**** ** ****** ** * *** *
* ******* ** *

}



int main(){
** *** * * ** ** * * ax,ay,bx,by;
* ** * *** * * ** * * * ** ** * * ** *** ** *
**** ** * * * * * ** * A(ax,ay);
* ** * ** ** * *** *** ** B(bx,by);
*** * ** ** * *** ** * **** * ** **** * * ** ** **
* * ** * * * * ** (A.equal_to(B)) ** *** ** * equal * ** ** ******
* * ** * * ** ** * * **** *** * ** not equal * * * * *** *
* * ***** **** * ** ** *****
* * * ************ * * * * * * *** * ** *
* * ** *** * * ** ** 0;

}
answered by (-264 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.17.59
©2016-2025

Related questions

0 like 0 dislike
23 answers
[Exercise] Coding (C) - asked May 11, 2017 in C++
ID: 24589 - Available when: Unlimited - Due to: Unlimited
| 2.3k views
0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked May 18, 2017 in C++
ID: 24769 - Available when: Unlimited - Due to: Unlimited
| 2.5k views
12,783 questions
183,442 answers
172,219 comments
4,824 users