게시판 게시물

joy001227
2020년 1월 22일
In 소스 코드 제출
#include <iostream> #include <string> using namespace std; /* class Circle { public: int radius; string name; Circle(int radius=0) { this->radius = radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } double getArea() { return 3.14*radius*radius; } // void show(){cout << "반지름이 " << radius << "인 " << name << endl;} }; class NamedCircle:public Circle { public: NamedCircle(); NamedCircle(int radius, string name); }; NamedCircle::NamedCircle() { } NamedCircle::NamedCircle(int radius, string name) { this->radius = radius; this->name = name; } class Cmp:public NamedCircle { public: CircleCompare(); }; int Cmp::CircleCompare() { return radius; } int main() { //NamedCircle waffle(3, "waffle"); // waffle.show(); Cmp pizza[5]; for(int i=0; i<5; i++) { cout << i+1 << ">> "; cin >> pizza[i].radius >> pizza[i].name; } int max = 0; int loc = 0; max = pizza[0].radius; for(int i=0; i<5; i++) { if(pizza[i].radius > max) { max = pizza[i].radius; loc = i; } } cout << "가장 면적이 큰 피자는 " << pizza[loc].name << "입니다." << endl; } */ /* class product{ public: int num; string name; string product; int price; Prodict(); Product(int num, string name, string product, int price){ this->num = num; this->name = name; this->product = product; this->price = price; } int getNum(){return num;} string getName() { return name; } string getProduct() { return product; } int getPrice() { return price; } }; class Book: public product{ public: string bookName; string writer; Book(){} Book(string bookName, string writer, int num, string name, string product, int price){ this->bookName = bookName; this->writer = writer; this->num = num; this->name = name; this->product = product; this->price = price; } void show(); string getBookName(){return bookName;} string getWriter(){return writer;} }; void Book::show(){ cout << "--- 상품ID : " << getNum() << endl; cout << "상품설명 : " << getName() << endl; cout << "생산자 : " << getProduct() << endl; cout << "가격 : " << getPrice() << endl; cout << "책제목 : " << bookName << endl; cout << "저자 : " << writer << endl; } class CompactDisc: public Product{ }; class ConversationBook: public Book{ }; int main(){ } */
0
0
3
joy001227
2020년 1월 21일
In 소스 코드 제출
#include <iostream> using namespace std; /* int sum(int a, int b){ int s=0; for(int i=a; i<=b; i++){ s+=i; } return s; } int sum(int a){ int s=0; for(int i=0; i<=a; i++){ s+=i; } return s; } int main() { cout << sum(3, 5) << endl; cout << sum(3) << endl; cout << sum(100) << endl; } */ /* int mul(int a, int b){ int m = 0; m = a*b; return m; } double mul(double a, double b){ double m=0; m=a*b; return m; } int main(){ double a; double b; cout << "a >> "; cin >> a; if( a/(int)a == 1){ a = (int)a; } cout << endl << "b >> "; cin >> b; if( a/(int)b == 1){ a = (int)b; } cout << endl << mul(a,b) << endl; } */ /* class Person{ public: int money; void addMoney(int money){ this->money += money; } static int sharedMoney; static void addShared(int n){ sharedMoney += n; } }; int Person::sharedMoney = 10; int main(){ Person han; han.money = 100; han.sharedMoney = 200; Person lee; lee.money = 150; lee.addMoney(200); lee.addShared(200); cout << han.money << ' ' << lee.money << endl; cout << han.sharedMoney << ' ' << lee.sharedMoney << endl; } */ /* class Circle{ private: static int numOfCircles; int radius; public: Circle(int r=1); ~Circle(){numOfCircles--;} double getArea(){return 3.14*radius*radius;} static int getNumOfCircles(){return numOfCircles;} }; Circle::Circle(int r){ radius = r; numOfCircles++; } int Circle::numOfCircles = 0; int main(){ Circle *p = new Circle[10]; cout << "생존하고 있는 원의 개수 = " << Circle::getNumOfCircles() << endl; delete [] p; cout << "생존하고 있는 원의 개수 = " << Circle::getNumOfCircles() << endl; Circle a; cout << "생존하고 있는 원의 개수 = " << Circle::getNumOfCircles() << endl; Circle b; cout << "생존하고 있는 원의 개수 = " << Circle::getNumOfCircles() << endl; } */ /* class student { public: int a, b, c; }; class school : public student { }; int main() { school rs; rs.a = 10; } */ #include <string> /* class Point{ int x; int y; public: void set(int x, int y){ this->x = x; this->y = y; } void showPoint(){ cout << "(" << x << "," << y << ")" << endl; } }; class ColorPoint : public Point { string color; public: void setColor(string color){this->color = color;} void showColorPoint(); }; void ColorPoint::showColorPoint(){ cout << color << ":"; showPoint(); } int main(){ Point p; ColorPoint cp; cp.set(3,4); cp.setColor("RED"); cp.showColorPoint(); } */ /* class parents { }; class child : public parents { }; int main() { parents *p = new parents; child *c; p->a; p = c; c = (child*)p; } */ /* class Point{ protected: int x; int y; public: void set(int x, int y){ this->x = x; this->y = y; } void setX(int x); int getX(); void setY(int y); int getY(); void showPoint(){ cout << "(" << x << "," << y << ")" << endl; } }; class ColorPoint : public Point{ string color; public: void setColor(string color) {this->color = color;} void showColorPoint(); bool equals(ColorPoint p); }; void Point::setX(int a) { this->x = a; } void Point::setY(int b){ this->y = b; } void ColorPoint::showColorPoint(){ cout << color << ":"; showPoint(); } bool ColorPoint::equals(ColorPoint p){ if(x == p.x && y == p.y && color == p.color){ return true; } else{ return false; } } int main(){ Point p; p.set(2,3); p.setX(5); p.setY(5); p.showPoint(); ColorPoint cp; cp.setX(10); cp.setY(10); cp.set(3,4); cp.setColor("RED"); ColorPoint cp2; cp2.set(3,4); cp2.setColor("RED"); cout << ((cp.equals(cp2))?"true :" : "false"); } */ class add { public: int sum; add(); add(int a[], int size); add(int a[], int size, int b[]); }; add::add(int a[], int size){ int sum = 0; for(int i=0; i<size; i++){ sum += a[i]; } this->sum = sum; } add::add(int a[], int size, int b[]){ int sum = 0; for(int i=0; i<size; i++){ sum += a[i] + b[i]; } this->sum = sum; } int main(){ int a[] = {1,2,3,4,5}; int b[] = {6,7,8,9,10}; add x(a,5); add y(a,5,b); cout << x.sum << endl; cout << y.sum << endl; }
0
0
3

joy001227

더보기