[C++] CHAPTER 11 실습 과제 1
·
C++
#include using namespace std; struct INFORMATION { string name; string adress; int ph; }; int main() { INFORMATION man; cout > man.name; cout > man.ph; cout > man.adress; cout
[C++] CHAPTER 11 샘플 코드
·
C++
// 샘플 코드 33 struct EnemySpaceShip { int x_coordinate; int y_coordinate; int weapon_power; }; EnemySpaceShip getNewEnemy() { EnemySpaceShip ship; ship.x_coordinate = 0; ship.y_coordinate=0; ship.weapon_power=20; return ship; } EnemySpaceShip upgradeWeapons(EnemySpaceShip ship) { ship.weapon_power += 10; return ship; } int main() { EnemySpaceShip enemy = getNewEnemy(); enemy = upgradeWeapons(enemy..
[C++] CHAPTER 10 과제
·
C++
// 초항과 공비를 입력받아 10칸 짜리 수열을 만들고 출력하는 코드 #include using namespace std; int main() { int array[10]; int first; int gap; cout > first; cout > gap; array[0] = first; cout
[C++] CHAPTER 10 샘플 코드
·
C++
// 샘플 코드 29 #include using namespace std; int main() { int array[8][8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { array[i][j] = i * j; } } cout
[C++] CHAPTER 9 실습 과제 3
·
C++
#include using namespace std; //x의 소인수를 구해서 전부 더하는 함수 int primeSum(int x) { int k = 2; int sum = 0; while (x != 1) { if (x % k == 0) { sum += k; x /= k; } else k++; } return sum; } //소인수들의 합이 소수인지 판별하는 함수 bool isPrimeSum(int sum) { for (int i = 2; i < sum; i++) { if (sum % i == 0) return false; } return true; } int main() { for (int i = 2; i
[C++] CHAPTER 8 실습 과제 2
·
C++
#include #include #include using namespace std; int main() { srand(time(NULL)); int num = rand() % (100 - 1 + 1) + 1; int guessnum; cout > guessnum; while (guessnum != num) { cout > guessnum; if (guessnum < num) { cout
[C++] CHAPTER 8 샘플 코드
·
C++
// 샘플 코드 26 #include #include int main() { srand(time(NULL)); } // 샘플 코드 27 #include #include #include using namespace std; int main() { srand(time(NULL)); cout
[C++] CHAPTER 7 샘플 코드
·
C++
// 샘플 코드 25 #include using namespace std; void playgame() {} void loadgame() {} void playmultiplayer() {} int main() { int input; cout
[C++] CHAPTER 6 실습 과제 3
·
C++
#include #include using namespace std; void password_judgment(); string password; string name; int main() { cout > password; cout > name; cout
[C++] CHAPTER 6 샘플 코드
·
C++
// 샘플코드 20 #include using namespace std; int add(int x, int y) { return x + y; } int main() { int result = add(1, 2); cout