8000 [명품 C++ 프로그래밍] 02장 C++ 프로그래밍의 기본 - 실습문제 · hellonayeon/c-cpp@f99d492 · GitHub
[go: up one dir, main page]

Skip to content

Commit f99d492

Browse files
committed
[명품 C++ 프로그래밍] 02장 C++ 프로그래밍의 기본 - 실습문제
1 parent e96aa23 commit f99d492

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
for(int i=1; i<=100; i++) {
6+
cout << i << "\t";
7+
8+
if (i%10 == 0) {
9+
cout << "\n";
10+
}
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
for (int i=1; i<=9; i++) {
6+
for (int j=1; j<=9; j++) {
7+
cout << j << "x" << i << "=" << j*i << '\t';
8+
9+
}
10+
cout << "\n";
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int num1, num2;
6+
7+
cout << "두 수를 입력하라 >> ";
8+
cin >> num1 >> num2;
9+
10+
int res = (num1 > num2) ? num1 : num2;
11+
cout << "큰 수 = " << res;
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
cout << "5 개의 실수를 입력하라 >> ";
7+
8+
float max = 0.0;
9+
for (int i=0; i<5; i++) {
10+
float num;
11+
cin >> num;
12+
13+
if (num > max) {
14+
max = num;
15+
}
16+
}
17+
18+
cout << "제일 큰 수 = " << max << endl;
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
int main() {
6+
string res1, res2;
7+
8+
cout << "가위 바위 보 게임을 합니다. 가위, 바위, 보 중에서 입력하세요." << '\n';
9+
10+
11+
cout << "로미오" << " >> ";
12+
cin >> res1;
13+
14+
cout << "줄리엣" << " >> ";
15+
cin >> res2;
16+
17+
if ((res1 == "가위" && res2 == "") || (res1 == "바위" && res2 == "가위") || (res1 == "" && res2 == "바위")) {
18+
cout << "로미오가 이겼습니다." << endl;
19+
}
20+
else if ((res2 == "가위" && res1 == "") || (res2 == "바위" && res1 == "가위") || (res2 == "" && res1 == "바위")) {
21+
cout << "줄리엣이 이겼습니다." << endl;
22+
}
23+
else {
24+
cout << "비겼습니다." << endl;
25+
}
26+
}

0 commit comments

Comments
 (0)
0