Skip to content

Commit c7bd361

Browse files
committed
local
1 parent 6c68b29 commit c7bd361

File tree

8 files changed

+170
-0
lines changed

8 files changed

+170
-0
lines changed

18-Programming-4kids/09_5.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int N, T, value;
6+
7+
cin >> T;
8+
9+
while (T--) {
10+
cin >> N;
11+
12+
int sum = 0;
13+
for (int i = 0; i < N; ++i) {
14+
cin >> value;
15+
16+
int result = 1;
17+
for (int j = 0; j < i + 1; ++j)
18+
result *= value;
19+
sum += result;
20+
}
21+
cout << sum << "\n";
22+
}
23+
24+
return 0;
25+
}
26+

18-Programming-4kids/09_6_A.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n, m, sum;
6+
7+
cin >> n >> m >> sum;
8+
9+
int cnt = 0;
10+
11+
for (int i = 1; i <= n; ++i)
12+
for (int j = 1; j <= m; ++j)
13+
if (i + j == sum)
14+
cnt++;
15+
16+
17+
cout << cnt << "\n";
18+
19+
return 0;
20+
}
21+

18-Programming-4kids/09_6_B.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n, m, sum;
6+
7+
cin >> n >> m >> sum;
8+
9+
int cnt = 0;
10+
11+
for (int i = 1; i <= n; ++i)
12+
{
13+
int j = sum - i; // i + j == sum
14+
15+
if (1 <= j && j <= m)
16+
cnt++;
17+
18+
}
19+
20+
cout << cnt << "\n";
21+
22+
return 0;
23+
}
24+

18-Programming-4kids/09_7_A.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n, m, w;
6+
7+
cin >> n >> m >> w;
8+
9+
int cnt = 0;
10+
11+
for (int i = 1; i <= n; ++i)
12+
for (int j = i; j <= m; ++j)
13+
for (int k = 1; k <= w; ++k)
14+
if (i + j <= k)
15+
cnt++;
16+
17+
cout << cnt << "\n";
18+
19+
return 0;
20+
}
21+

18-Programming-4kids/09_7_B.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n, m, w;
6+
7+
cin >> n >> m >> w;
8+
9+
int cnt = 0;
10+
11+
for (int i = 1; i <= n; ++i)
12+
for (int j = 1; j <= m; ++j) {
13+
int k = i + j;
14+
15+
if (1 <= k && k <= w)
16+
cnt += w - k + 1;
17+
}
18+
19+
cout << cnt << "\n";
20+
21+
return 0;
22+
}
23+

18-Programming-4kids/09_8_ِA.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n = 10;
6+
7+
int a = 0, b = 1;
8+
9+
cout<<a<<" "<<b<<" ";
10+
11+
for (int a = 0, b = 1, cnt = 2; cnt < n; ++cnt) {
12+
int c = a+b;
13+
a = b;
14+
b = c;
15+
16+
cout<<c<<" ";
17+
}
18+
19+
return 0;
20+
}
21+

18-Programming-4kids/09_8_ِB.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n = 10;
6+
7+
for (int a = 0, b = 1, c = -1, cnt = 0; cnt < n;
8+
++cnt, c = a + b, a = b, b = c)
9+
cout << a << " ";
10+
11+
return 0;
12+
}
13+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n;
6+
7+
cin>>n;
8+
9+
for (int i = 0; i < n; ++i) {
10+
for (int j = 0; j < n; ++j) {
11+
if(i == j || n-i-1 == j)
12+
cout<<"*";
13+
else
14+
cout<<" ";
15+
}
16+
cout<<"\n";
17+
}
18+
19+
return 0;
20+
}
21+

0 commit comments

Comments
 (0)