Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03
diff options
context:
space:
mode:
diff --git a/Sem. 03/README.md b/Sem. 03/README.md
index 427d736..af93bf2 100644
--- a/Sem. 03/README.md
+++ b/Sem. 03/README.md
@@ -67,9 +67,9 @@ do
**Задача 2:** Да се напише програма, която приема 2 числа. Да се отпечатат всички общи делители сортиран наобратно.
-*Вход: 28 21, Изход: 7 3 1*
+*Вход: 28 21, Изход: 7 1*
-*Вход: 60 30 Изход: 30 15 10 5 3 1*
+*Вход: 60 30 Изход: 30 15 10 6 5 3 2 1*
*Вход: 5 4 3 0 Изход: 12*
diff --git a/Sem. 03/example 10 - matrix b/Sem. 03/example 10 - matrix
new file mode 100644
index 0000000..dae43ab
--- /dev/null
+++ b/Sem. 03/example 10 - matrix
@@ -0,0 +1,25 @@
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int count;
+ cin >> count;
+
+ for (int i = 1; i <= count; i++)
+ {
+ for (int j = 0; j < count; j++)
+ {
+ if (j % 2 == 0)
+ {
+ cout << i + (count * j) << " ";
+ }
+ else
+ {
+ cout << (j + 1) * count - (i - 1) << " ";
+ }
+ }
+ cout << endl;
+ }
+}
diff --git a/Sem. 03/solutions/exercise 8 - dollar pyramid.cpp b/Sem. 03/solutions/exercise 8 - dollar pyramid.cpp
new file mode 100644
index 0000000..65f6106
--- /dev/null
+++ b/Sem. 03/solutions/exercise 8 - dollar pyramid.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+
+ int n;
+ cin >> n;
+
+ for(int i = 1; i <= n; i++)
+ {
+ for(int j = 1; j <= i; j++)
+ cout << "$" << " "; // print as many dollars as the number of the current row
+
+ cout << endl;
+ }
+
+ return 0;
+} \ No newline at end of file
diff --git a/Sem. 03/solutions/exercise 9 - rightmost pyramid.cpp b/Sem. 03/solutions/exercise 9 - rightmost pyramid.cpp
new file mode 100644
index 0000000..d1b339a
--- /dev/null
+++ b/Sem. 03/solutions/exercise 9 - rightmost pyramid.cpp
@@ -0,0 +1,36 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+
+ int n;
+ cin >> n;
+
+ // print the first part of the pyramid (the one going from 1 to n(n-1)...21)
+
+ for(int i = 1; i <= n; i++)
+ {
+ for(int k = n - i - 1; k >= 0; k--)
+ cout << " "; // print the spaces
+
+ for(int j = i; j >= 1; j--)
+ cout << j; // print numbers j(j - 1)...21
+
+ cout << endl;
+ }
+ // print the second part of the pyramid (the one going from (n-1)...21 to 1
+
+ for(int i = n - 1; i >= 1; i--)
+ {
+ for(int k = n - i - 1; k >= 0; k--)
+ cout << " ";
+
+ for(int j = i; j >= 1; j--)
+ cout << j;
+
+ cout << endl;
+ }
+
+ return 0;
+} \ No newline at end of file