Converted everything to orgmode

converted everything to orgmode and added solution to the README files
This commit is contained in:
2025-03-31 08:40:43 +02:00
parent 8719f4c140
commit 88e0b5ed69
88 changed files with 1942 additions and 2989 deletions

View File

@@ -1,8 +0,0 @@
_This task is a text-based task. You do not need to write any program/C++ file: the answer should be written in functions.cpp._
Consider the functions implemented in `functions.cpp`. For each function, add proper pre- and post-conditions.
- If no pre-condition is needed, you can simply write "n/a".
- The post-condition does not have to be a mathematical formula, e.g. it can be an informal description, but it must completely characterize the results and effects of the functions depending on the provided parameters.
**Note**: For the purposes of this task, you can ignore overflows.

View File

@@ -0,0 +1,57 @@
#+TITLE: Task 2: Pre- and post-conditions
/This task is a text-based task. You do not need to write any program/C++ file: the answer should be written in functions.cpp./
Consider the functions implemented in =functions.cpp=. For each function, add proper pre- and post-conditions.
- If no pre-condition is needed, you can simply write "n/a".
- The post-condition does not have to be a mathematical formula, e.g. it can be an informal description, but it must completely characterize the results and effects of the functions depending on the provided parameters.
**Note**: For the purposes of this task, you can ignore overflows.
* Solution
#+begin_src cpp
// PRE: x > 0
// POST: returns n^x
int f1(int n, int x) {
int res = 1;
for (; x > 0; x--) {
res *= n;
}
return res;
}
// PRE: n > 0
// POST: returns number of devisions by 10 with n
int f2(int n) {
int i = 0;
while (n > 0) {
n = n / 10;
++i;
}
return i;
}
// PRE: n > 1
// POST: returns a bool to determine if n is prime
bool f3(int n) {
int i = 2;
for (; n % i != 0; ++i);
return n == i;
}
// PRE: n is square number
// POST: returns root of n
int f4(int n) {
int i = 0;
while (i * i != n) {
++i;
}
return i;
}
#+end_src
-----
Made by JirR02 in Switzerland 🇨🇭

View File

@@ -1,38 +0,0 @@
// PRE: x > 0
// POST: returns n^x
int f1(int n, int x) {
int res = 1;
for (; x > 0; x--) {
res *= n;
}
return res;
}
// PRE: n > 0
// POST: returns number of devisions by 10 with n
int f2(int n) {
int i = 0;
while (n > 0) {
n = n / 10;
++i;
}
return i;
}
// PRE: n > 1
// POST: returns a bool to determine if n is prime
bool f3(int n) {
int i = 2;
for (; n % i != 0; ++i);
return n == i;
}
// PRE: n is square number
// POST: returns root of n
int f4(int n) {
int i = 0;
while (i * i != n) {
++i;
}
return i;
}