1. 2

2. 1

3. 3

4. 4

5. 2,4

6. 1,2,4

7.

(1) 업캐스팅: 2  다운캐스팅: 3

(2) q가 가리키는 객체공간에는 y가 없다. 

8.

(1). 3

(2). w,x,z

(3). 3

(4). dp = (D *)ap;

9. 

(1). 

생성자A

생성자B

(2). 

생성자A

생성자B10

(3). 

생성자A32

생성자B400

10.

(1). 7,8번째줄. A를 상속받는데 A의 기본생성자가 없다.

(2). (3). 

class A
{
public:
	A() {}
	A(int x) { cout << "생성자A" <<x<< endl; }
};
class B : public A
{
public:
	B():A(20) { cout << "생성자B" << endl; }
	B(int x) : A(x+20) { cout << "생성자B" << x << endl; }
};

11.3

12. 4

13.

class Satellite : public Rocket, public Computer 
{
};

14.

(1).

class Pen{};
class Eraser{};
class Hopen : public Pen, public Eraser {};

(2). 

class Pen{};
class Eraser{};
class Lock{};
class HiPen : public Pen, public Eraser {};
class OmniPen : public Pen, public Eraser, public Lock {};

15. 4, 

컴파일 오류의 원인: power변수가 중복되어 생성되서 다중상속의 모호성이 발생하게 된다. 

해결:

class Vehicle
{
public: int power;
};
class Car : virtual public Vehicle
{
public: int color;
};
class Airplane :virtual public Vehicle
{
public: int altitude;
};
class FlyingCar : public Car, public Airplane
{
public: void go();
};

 

16. ColorTV와 InternetTV가 모두 상속되는 클래스가 있을 경우 TV클래스의 멤버 screenSize가 중복되어 메모리 할당되게 된다. 그래서 다중상속의 모호성이 발생하게된다. 

해결방안:

class TV
{
public: int screenSize;
};
class ColorTV : virtual public TV
{
public: int color;
};
class InternetTV : virtual public TV
{
public: string ipAdder;
};

 

1. 1

2. 4

3.

class Sample{

friend SampleManager;

};

4. 

class Sample
{
friend bool SampleManager::compare(Sample& a, Sample& b);
};

5.

원인: 클래스의 멤버가 아닌 isValid함수가 Student클래스 객체의 private변수에 접근해서

고친것: 

class Student
{
int id;
public:
Student(int id) { this->id = id; }
friend bool isValid(Student s);
};

6.

원인: 멤버함수가 아닌 함수에서 private변수에 접근해서.

고친 것:

class Student;
class Professor;

class Student
{
	int id;
public:
	Student(int id) { this->id = id; }
	friend void show(Student s, Professor p);
};

class Professor
{
	string name;
public:
	Professor(string name) { this->name = name; }
	friend void show(Student s, Professor p);
};

void show(Student s, Professor p)
{
	cout << s.id << p.name;
}

7.

오류: shopping함수에서 부적절하게 Food객체의 멤버변수에 접근해서.

class Person;
class Food;

class Food
{
	int price;
	string name;
public:
	Food(string name, int price);
	void buy();
	friend Person;
};

class Person
{
	int id;
public:
	void shopping(Food food)
	{
		if (food.price < 1000)
			food.buy();
	}
	int get() { return id; }
};

8. 4

9. friend함수는 멤버가 아니기 때문에 객체의 멤버처럼 호출될수 없다. 그래서 friend 를 지워야 한다. 

10. 필요없다. 변수 x가 private으로 선언되지 않았기 때문에 굳이 friend를 붙여주지 않아도 된다. 

11. cout객체의 <<연산자로서 문자를 출력하기도 하고, 

12. 밀가루 + 계란 = 빵

13. 4 

14. 4

15. 3

16. 4?

3번, 참조로 값을 받아야 한다. Power operator ++ (Power& a, int b)

17. 복사할 필요 없다. 내용만 복사되는것이고 하나의 객체가 되는것이 아니기 때문이다. 

 

1. 2

2. 3

3. 3,4

4. 1,2

5. 2

6. 2

7. 4

8. 2

9. 3

10. 2

11. 4 소멸자는 오직 한개만 존재하며 매개변수를 가지지 않는다. 

12. 

(1). 0

(2). 3

(3). 5Hello

13. f(3)을 호출하면 int f(int a)를 호출해야할지 디폴트매개변수가 있는 int f(int a, int b=0)을 호출해야 할지 알 수 없다.

14. area(3.14)를 호츨하면 area(float f)를 호출할지 area(double d)를 호출할지 알 수 없다.

컴파일러가 실인자를 자동형 변환 할때 형변환의 모호성이 발생한다.

15. 4 static멤버함수는 static멤버들만 접근할 수 있다.

16. 3 s는 클래스 명이 아니니까

 

1. 4

2. 1

3. 주소에 의한 전달방식

4.

(1). o

(2). x

5. 

(1). 5

(2). 25

6. 1 4 9

7. 2

8. 2

9. 1

10.

(1). { 0,2,4,6,8,10,12,14,16,100}

(2). {0,4,6,8,10,12,14,16,18,18}

(3). {0,2,4,6,8,10,12,14,16,18}

(4). {0,2,4,6,0,10,12,14,16,18}

11. 

이유: 값에의한 호출이기 때문에

고친 것:

void copy(int& dest, int& src)

{

dest = src;

}

12. 

x = 1, y = 2  이유: z는 없어지는 매개변수 b의 별명이므로

x = 1, y = 100 이유: w와 b와 y는 모두 같은 공간을 가리킨다.

13.

기본생성자: MyClass() {}

복사생성자: MyClass(const Myclass& m)

14. 2

15. 

(1). ~MyClass() { delete[] element; }

(2).  

MyClass(const MyClass& m)
{
this->size = m.size;
this->element = m.element;
}

(3). 

MyClass(const MyClass& m)
{
this->size = m.size;
this->element = new int;
*(this->element) = *(m.element);
}

https://starfish22.tistory.com/81

 

명품 C++ 5장 연습문제 - 이론 문제

1. 4번 디폴트 복사 생성자를 묵시적으로 삽입 2. 1번 값을 복사하기 때문에 3. 주소에 의한 호출 4. (1) 같다. 함수 인자 전달 방식이 주소에 의한 호출이다. (2) 다르다. 함수 인자 전달 방식이 *p는

starfish22.tistory.com

MyClass(const MyClass& m)
{
this->size = m.size;
this->element = new int[size];
for (int i = 0; i < size; i++)
this->element[i] = m.element[i];
}

 

16. 1

17. 

Student(const Student& s)
{
this->name = s.name;
this->id = s.id;
this->grade = s.grade;
}

18.

Student(const Student& s)
{
this->pName = s.pName;
this->pId = s.pId;
this->grade = s.grade;
}

19.

a와b의 element 포인터변수가 같은 메모리공간을 가리킨다. 

1.

(1).  Rect* p;

(2).  p = &r

(3). cout<< p->getWidth() << p->getHeight();

2.

(1). q = new Rect(w, h);
(2). cout << "사각형의 면적은 " << q->getArea();
(3). delete q;

3. 1 (생성자가 하나라도 선언된 클래스의 경우, 컴파일러는 기본 생성자를 자동 삽입하지 않는다.-117p)

4.  기본생성자 추가 Rect() { width = 1; height = 1; }

5.

int main()
{
	Rect r[5] = { Rect(), Rect(2,3),Rect(3,4),Rect(4,5),Rect(5,6) };
	int sum = 0;
	for (int i = 0; i < 5; i++)
	{
		sum += r[i].getArea();
	}
	cout << "면적의 합은 " << sum;
}

6. 4

7. 4동적할당이 아니니까.

8. 

기본생성자

기본생성자

기본생성자

소멸자

소멸자

소멸자

9. 1

10. delete [ ]p;

11. 3 

12. 3

13.

#include <iostream>
#include <string>
using namespace std;

class Location
{
	int width, height;
public:
	Location() { this->width = this->height = 0; }
	Location(int width, int height)
	{
		this->width = width; this->height = height;
	}
	void show();
};
void Location::show()
{
	cout << this->width << this->height << endl;
}

14.

 동적으로 할당받은 메모리 주소를 잃어버려 힙에 반환할수 없게 되면 메모리 누수가 일어난다 

15. 

(1). 

void f()
{
	char* p = new char[10];
	strcpy(p, "abc");
	delete[] p;
}

(2). 발생하지 않음

(3). 발생하지 않음

(4).

void f()
{
	int* p;
	for (int i = 0; i < 5; i++)
	{
		p = new int;
		cin >> *p;
		if (*p % 2 == 1)
		{
			delete p;
			break;
		}
		delete p;
	}
}

16. 1

17. stoi, stoi

18. 3

19.

int main()
{
	string a = "My name is Jane";
	char ch = a[2];
	if (a == "My name is John") cout << "same";
	a = a + "~~";
	a[1] = 'Y';
}

 

199p 예제 4-13

내답:

#include <iostream>
#include <string>
#include <locale>
using namespace std;

int main()
{
	//빈칸을 포함하는 문자열을 입력받고, 한 문자씩 왼쪽으로 회전하도록 문자열을 변경하고 출력
	cout << "아래에 문자열을 입력하세요. 빈 칸이 있어도 됩니다.(한글안됨)" << endl;
	string str;
	getline(cin, str, '\n');
	int length = str.length();

	char a;
	string str1= str.substr(1);
	for (int i = 0; i < length; i++)
	{
		a = str[i];
		str1 += a;
		cout << str1 << endl;
		str1 = str1.substr(1);
	}
}

더럽다 코드 더럽다

책답:

#include <iostream>
#include <string>
#include <locale>
using namespace std;

int main()
{
	string s;
	cout << "아래에 문자열을 입력하세요. 빈 칸이 있어도 됩니다.(한글안됨)" << endl;
	
	getline(cin, s, '\n');
	int length = s.length();

	for (int i = 0; i < length; i++)
	{
		string first = s.substr(0,1);
		string sub = s.substr(1, length - 1);
		s = sub + first;
		cout << s << endl;
	}
}

 

open Challenge 204p 

내답:

int main()
{
	cout << "끝말 잇기 게임을 시작합니다." << endl;
	cout << "게임에 참가하는 인원은 몇명입니까?";
	int n;
	cin >> n;
	string* Name = new string [n];
	for (int i = 0; i < n; i++)
	{
		cout << "참가자의 이름을 입력하세요. 빈칸없이>>";
		cin >> Name[i];
	}
	cout << "시작하는 단어는 아버지입니다." << endl;
	string a = "아버지";
	while (1)
	{
		for (int i = 0; i < n; i++)
		{
			cout << Name[i] << ">>";
			string b;
			cin >> b;

			int length = a.length();
			if (a.at(length - 2) == b.at(0) &&
				a.at(length-1)== b.at(1))
			{
				a = b;
			}
			else
			{
				cout << Name[i] << "이 졌습니다." << endl;
				cout << "게임을 종료합니다." << endl;
				return 0;
			}
		}
	}
}

해답:

#include <iostream>
#include <string>
using namespace std;
class WordGame
{
	Player* p;
	int num;
	public:
		WordGame(int num);
		~WordGame() { delete[] p; }
		void game();
	
};
class Player
{
	string name;
public:
	void setName(string name) { this->name = name; }
	string getName() { return name; }
};

WordGame::WordGame(int num) {
	this->num = num;
	p = new Player[num];
}

void WordGame::game() {
	string n;
	for (int i = 0; i < num; ++i) {
		cout << "참가자의 이름을 입력하세요. 빈칸 없이>>";
		cin >> n;
		p[i].setName(n);
	}
	cout << endl;
	cout << "시작하는 단어는 아버지입니다" << endl;
	string a = "아버지";
	string b;
	int i = 0;
	for (;;) {
		cout << p[i % num].getName() << ">>";
		cin >> b;
		int j = a.size();
		if (a.at(j - 2) == b.at(0) && a.at(j - 1) == b.at(1)) {
			a = b;
		}
		else {
			cout << p[i % num].getName() << "탈락!!" << endl;
			break;
		}
		++i;
	}
}
int main()
{
	cout << "끝말 잇기 게임을 시작합니다" << endl;
	cout << "게임에 참가하는 인원은 몇명입니까?";
	int num;
	cin >> num;
	WordGame wordgame(num);
	wordgame.game();
}

출처: 명품 C++ 4장 Open Challenge :: 건호의 코딩공부 (tistory.com)

 

 

Open Challenge 143p

Exp.cpp

#include <iostream>
using namespace std;

#include "Exp.h"

int Exp::getBase()
{
	return base;
}

int Exp::getExp()
{
	return exp;
}
int Exp::getValue()
{
	//지수승 표현하기
	int num = exp;
		if (num == 1 && base ==1)
		{
			res = 1 ;
			return res;
		}
		else if (num == 1 && base != 1)
		{
			res = base;
			return res;
		}
		while (1)
		{
			if (num != 0)
			{
				res *= base;
				num--;
			}
			else
				return res;
		}
}

bool Exp::equals(Exp b)
{
	if (res == b.res)
		return true;
	else
		return false;
}

Exp.h

#ifndef ADDER_H
#define ADDER_H
class Exp
{
	int base;
	int exp;
public:
	int res;
	Exp()
	{
		base = 1; exp = 1; res = 1;
	};
	Exp(int x, int y)
	{
		base = x; exp = y; res = 1;
	}
	Exp(int z)
	{
		base = z; exp = 1; res = 1;
	}
	int getBase();
	int getExp();
	int getValue();
	bool equals(Exp b);
};
#endif

 

내 exp.cpp코드는 별로 안좋은 코드인것 같다. 

- res변수 하나를 public으로 옮긴것

- getValue도 간결하지 못하다고 생각한다. 

https://godog.tistory.com/entry/%EB%AA%85%ED%92%88-C-programming-3%EC%9E%A5-Open-Challenge 

 

명품 C++ programming 3장 Open Challenge

1. 문제 실수의 지수 표현을 클래스 Exp로 작성하라. Exp를 이용하는 main() 함수와 실행 결과는 다음과 같다. 클래스 Exp를 Exp.h 헤더 파일과 Exp.cpp 파일로 분리하여 작성하라. 2. 결과 3. 코드 // main 파

godog.tistory.com

이 분의 코드가 내 코드보다 더 간결하고 정제된것 같아서 이 분 코드로 고쳤다. ㅠㅠ

 

연습 이론문제

1. 객체의 내부를 볼수없게하고 외부로 부터 접근으로부터 보호하기 위해서. 

2. 3

3. private로 보호받고있는 멤버변수,함수가 없기 때문에 캡슐화가 아니다.

4.

class Circle
{
	int age;
	int radius;
public:
	double getArea();
	void older();
};

5. 맨 마지막 중괄호 } 뒤에 ; 를 붙인다

6. 생성자는 리턴타입을 선언해서는 안된다.

class Tower
{
	int height = 20;
public:
	Tower()
	{
		height = 10;
	}
};

7.

class Building
{
private:
	int floor;
public:
	Building(int s) { floor = s; }
	Building() { floor = 5; }
};

int main()
{
	Building twin, star;
	Building BlueHouse(5), JangMi(14);
}

8.

class Calendar
{
private:
	int year;
public:
	Calendar();
	int getYear();
};

Calendar::Calendar()
{
	year = 10;
}

int Calendar::getYear()
{
	return year;
}

9. 2

10. 3

11. 

(1)(2)

#include <iostream>
using namespace std;

class House
{
	int numOfRooms;
	int size;
public:
	House(int n, int s);
	~House();
};

House::House(int n, int s)
{
	numOfRooms = n; size = s;
	cout << "방 번호: " << numOfRooms << "그리고 크기 : " << size << endl;
}
House::~House()
{
	cout << "방 번호: " << numOfRooms << "그리고 크기 : " << size<<endl;
}

void f()
{
	House a(2, 20);
}
House b(3, 30), c(4, 40);

int main()
{
	f();
	House d(5, 50);
}

(3). 

b-c-a-a-d-d-c-b

12. c-b-a-a-b-c

13.  매개변수 없는 생성자 TV()가 private 지정자로 되어있어 main함수에서 생성자가 호출될수가 없다. 

class TV
{
public:
	int channels;
	TV(int a) { channels = a; }
	TV() { channels = 256; }
};

int main()
{
	TV LG;
	LG.channels = 200;
	TV Samsung(100);
}

14. channels 변수가 private로 지정되어있어 main함수에서 직접 접근이 불가능하다. 

class TV 
{
public:
	int colors;
	int channels;
	TV() { channels = 256; }
	TV(int a, int b) { channels = a; colors = b; }
};
int main()
{
	TV LG;
	LG.channels = 200;
	LG.colors = 60000;
	TV Samsung(100, 50000);
}

 

15. TV()생성자, TV(int a) 생성자, getChannels()함수

16. 2

17. 1

18. 1

19. 4

20.

class Family
{
private: 
	char tel[11];
public:
	int count;
	char address[20];
	Family();
};

21.

struct Universe
{
	Universe();
private:
	char dataCreated[10];
	char creator[10];
	int size;
};

76p 공백문자를 입력받아 공백문자인지 아닌지 출력하는 함수 ... 를 작성해봤는데 

왜 실행결과가 안나오는지 모르겠다..ㅠㅠㅠ

#include <iostream> 
#include <cstring>
#include<cctype>
using namespace std;

int main()
{
	char c;
	cin >> c;
	cout << "c는 공백문자가 " ;
	if (isspace(c) == 0)
		cout << "아니다";
	else if(isspace(c) != 0)
		cout << "맞다";
}

Open Challenge83p

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	cout << "가위 바위 보 게임을 합니다. 가위, 바위, 보 중에서 입력하세요." << endl;

	cout << "로미오>>";
	string rom;
	cin >> rom;
	
	cout << "줄리엣>>";
	string jul;
	cin >> jul;

	if (rom == "가위")
	{
		if (jul == "가위")
			cout << "비겼습니다.";
		else if (jul == "바위")
			cout << "줄리엣이 이겼습니다. ";
		else if (jul == "보")
			cout << "로미오가 이겼습니다. ";
	}
	else if (rom == "바위")
	{
		if (jul == "가위")
			cout << "로미오가 이겼습니다.";
		else if (jul == "바위")
			cout << "비겼습니다. ";
		else if (jul == "보")
			cout << "줄리엣이 이겼습니다. ";
	}
	else if (rom == "보")
	{
		if (jul == "가위")
			cout << "줄리엣이 이겼습니다..";
		else if (jul == "바위")
			cout << "로미오가 이겼습니다. ";
		else if (jul == "보")
			cout << "비겼습니다. ";
	}
}

chapter02 c++프로그래밍의 기본

1. int main()

2. 3

3. return 0; 라인

4. 

(1) ??

(2) 프로그램 어디든지 변수를 선언할수 있다는 특징.

(3)

장점: 코드를 읽기 쉽게 만들고, 변수이름을 잘못 타이핑했을때의 실수를 줄일 수 있다. 

단점: 선언된 변수를 한눈에 보기 힘들고, 코드사이에 선언된 변수를 찾기가 힘들다. 

5. 

I love C++

I love programming

6. 

(1) using namespace std;

(2) using namespace std;

7. 

(1) #include <iostream>

(2) using namespace std;

(3) std::cin >> name;

(4) std::cout << 1 << 2 << 'a << "Hello" << '\n'

8.

(1) 틀린부분 없음. 

(2) 틀린부분 없음.

(3) int n =1; cout << n+200;

(4) int year = 2014; cout << 2014 << "년";

9. #include "myheader.h"

10. 
(1). o

(2). o

(3). o

(4). x

(5). x (>> 연산자는 공백문자를 만나면 그 전까지 입력된 문자들을 하나의 문자열로 인식한다. )

11. #include<cstring>

12. 

(1) kitae님 환영합니다.

(2) kitae님 환영합니다.

13. 4 (3번째 매개변수를 안쓰면 '\n'이 디폴트값으로 들어간다.)

14. 1 ( 4번에서 '.'을 만나지 못했지만 지정한 배열의 크기를 다 사용했기때문에 엔터입력까지만 읽게 된다.)

15. namespace

16. std

17. std

18. iostream

19.

#include <iostream>
using namespace std;
int main()
{
	int age = 20;
	const char* pDept = "컴퓨터 공학과";
	cout << age << ' ' << pDept;
}

20.

#include <iostream>
using namespace std;
int main()
{
	for (int n = 0; n < 4; n++)
	{
		for (int j = 0; j <= n; j++)
		{
			cout << "*";
		}
		cout << endl;
	}
}

<실습문제>

1.

#include <iostream>
using namespace std;
int main()
{
	for (int i = 1; i <= 100; i++)
	{
		cout << i << '\t';
		if ((i % 10) == 0)
		{
			cout << endl;
		}
	}
}

2.

#include <iostream>
using namespace std;
int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			cout << j << 'x' << i << "=" << j * i<<'\t';
			if ((j % 9) == 0)
			{
				cout << endl;
			}
		}
	}
}

3.

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cout << "두 수를 입력하라>>";
	cin >> a >> b;
	if (a > b)
		cout << "큰 수: " << a;
	else
		cout << "큰 수: " << b;
}

4.

#include <iostream>
using namespace std;
int main()
{
	double num[5], temp;
	cout << "5개의 실수를 입력하라>>";
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];
	//제일 큰 수 구하기
	for (int i = 1; i <= 4; i++)
	{
		if (num[0] < num[i])
		{
			temp = num[0];
			num[0] = num[i];
			num[i] = temp;
		}
	}
	cout << "제일 큰 수: " << num[0];
}

5.

#include <iostream>
using namespace std;
int main()
{
	cout << "문자들을 입력하라(100개 미만)."<<endl;
	char str[100];
	int sum = 0;
	cin.getline(str, 100);
	for (int i = 0; i < 100; i++)
	{
		if (str[i] == 'x')
			sum++;
	}
	cout << "x의 개수는 " << sum;
}

6.

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	// 문자열을 두개 입력받고 두개의 문자열이 같은지 검사하는 프로그램
	// 같으면 같습니다, 아니면 같지 않습니다 출력
	string a, b;
	cout << "새 암호를 입력하세요>>";
	cin >> a;
	cout << "새 암호를 다시 입력하세요>>";
	cin >> b;
	if (a==b)
		cout << "같습니다.";
	else
		cout << "같지 않습니다.";
}

7.

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	//yes 를 입력할때까지 종료하지 않는 프로그램 작성 
	char str[10];
	do
	{
		cout << "종료하고싶으면 yes를 입력하세요>>";
		cin.getline(str, 10);
		if (strcmp(str, "yes") == 0)
		{
			cout << "종료합니다" << endl;
			break;
		}
	} while (strcmp(str, "yes"));
}

8. 구려... 너무 구려... 왜 cin.getline도 안썼지.. 

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	cout << "5 명의 이름을 ';'으로 구분하여 입력하세요"<< endl;
	cout << "<<";
	char Five_name[100];
	int Colon_num[5];
	int sum = 0, num = 0;
	cin.getline(Five_name, 100);
	// 각 몇번째에 세미콜론이 있는지 파악
	for (int i = 0;i<100 ; i++)
	{
		if (Five_name[i] != ';')
		{
			sum++;
		}
		else
		{
			Colon_num[num] = ++sum;// 몇번째에 ;가 있는지
			num++;
		}
	}
	for(int i = 0; i<5;i++)
	cout << Colon_num[i]<<endl;

	int temp = 0;
	// 이름1~5까지 세미콜론까지 출력 
	for (int i = 0; i < 5; i++)
	{
		cout << i+1 << " : ";
		for (int j = temp; j < Colon_num[i]-1 ; j++)
		{
			cout << Five_name[j];
		}
		temp = Colon_num[i];
		cout << endl;
	}

	//가장 긴 이름 출력
	int long_str[5]; // 이름글자수 넣는 배열
	long_str[0] = Colon_num[0];
	for (int i = 0; i < 4; i++)
	{
		long_str[i + 1] = Colon_num[i + 1] - Colon_num[i];
	}

	int temp2;
	int length;// 인덱스상 몇번째 이름인지
	for (int i = 0; i < 4; i++) // 이름 글자수 넣어서 
	{
		if (long_str[0] < long_str[i + 1]) 
		{
			temp2 = long_str[0];
			long_str[0] = long_str[i + 1];
			long_str[i + 1] = temp2;
			length = i + 1;
		}
	}
	//출력
	cout << "가장 긴 이름은 ";
	for (int i = Colon_num[length-1]; i < Colon_num[length]-1 ; i++)
	{
		cout << Five_name[i];
	}
}//Mozart;Elvis Presley;Jim Carry;Schubert;Dominggo;

https://cocoon1787.tistory.com/126 를 보고 다시했다..  봐도 모르겠다...

 

9.

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	cout << "이름은?";
	char name[17];
	cin.getline(name,17);
	
	cout << "주소는?";
	char address[100];
	cin.getline(address,100);

	cout << "나이는?";
	int age;
	cin >> age;

	cout << name << " , " << address << " , " << age<<"세";
}

 

이 이후로 난이도 5이상문제는 일단 안풀고 넘어가고, 

이론문제와 실습문제 난이도 3,4만 푼 다음

끝까지 보고 다시 돌아와서 2회독때 난이도 5이상의 문제들을 풀어볼 생각이다.

 

+ Recent posts