Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit1b98fe49903e649851bc85f1786906fd5a2bb2db (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-12 09:52:24 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-12 09:52:24 +0300
Filesb922a5cabcaf1a2bdba816c0b6d2cd03eb2892e9
uni-projects-1b98fe49903e649851bc85f1786906fd5a2bb2db.tar
uni-projects-1b98fe49903e649851bc85f1786906fd5a2bb2db.tar.gz
uni-projects-1b98fe49903e649851bc85f1786906fd5a2bb2db.zip
Parent84402549c630e09ec80ddd04f9886d11d2e75902 (diff)
Added yesterday's practice
1 files changed, 38 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Practice-11.10.21.cpp38
diff --git a/Year 1/Programming introduction/Practice-11.10.21.cpp b/Year 1/Programming introduction/Practice-11.10.21.cpp
new file mode 100644
index 0000000..370fc77
--- /dev/null
+++ b/Year 1/Programming introduction/Practice-11.10.21.cpp
@@ -0,0 +1,38 @@
+#include <iostream>
+
+using namespace std;
+
+void ex0() {
+ cout << (char)43;
+}
+
+void ex1() {
+ int a;
+ cin >> a;
+ cout << a * (1 + a) / 2; // sum of arithmetic sequence, where a0 = 1 and d = 1
+}
+
+void ex2() {
+ int a;
+ cin >> a;
+ cout << ((a % 3 == 0) != (a % 5 == 0)); // != is logical XOR
+}
+
+void ex3() {
+ int a;
+ cin >> a;
+ cout << a / 3 + a / 5 - (a / 5) / 3;
+}
+
+void ex4() {
+ int a;
+ cin >> a;
+ a /= 3;
+ cout << (6 + (a - 1) * 3) * a / 2; // sum of arithmetic sequence, where a0 = 3 and d = 3
+}
+
+// Building and running in PowerShell:
+// g++ .\*.cpp -o out.exe; if($?) { .\out.exe }
+int main() {
+ ex4();
+}