TU-Programmieren_2/exercise1/main.ipynb
2025-04-09 10:22:44 +02:00

205 lines
5.9 KiB
Plaintext

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabe 1: Konfigurieren und Testen der eigenen Umgebung (1 Punkt)\n",
"\n",
"1. Konfigurieren Sie Ihr eigenes System: https://sgit.iue.tuwien.ac.at/360050/setup\n",
"\n",
"2. Nachdem Sie Ihre Konfiguration abgeschlossen haben, testen Sie Ihre Konfiguration indem Sie folgenden drei mitgelieferte Tests ausführen:\n",
"\n",
"\t- [task1.test.py](task1.test.py) testet die Python-Konfiguration. \n",
"\t- [task1.test.c](task1.test.c) testet die C-Konfiguration.\n",
"\t- [task1.test.cpp](task1.test.cpp) testet die C++-Konfiguration."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Kompilieren/Ausführen \n",
"\n",
"Mittels manueller Aufrufe (`gcc/g++/python`):\n",
"```shell\n",
"# prepare folder\n",
"mkdir build\n",
"# compile for task1\n",
"gcc -Imodules -std=c11 -g task1.test.c -o build/task1_c.exe\n",
"g++ -Imodules -std=c++20 -g task1.test.cpp -o build/task1_cpp.exe\n",
"# run tests for task1\n",
"python task1.test.py # produces \"info_python.txt\"\n",
"./build/task1_c.exe # produces \"info_c.txt\"\n",
"./build/task1_cpp.exe # produces \"info_cpp.txt\"\n",
"```\n",
"\n",
"Alternativ mittels *CMake* (optional):\n",
"```shell\n",
"# prepare compilation\n",
"cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug\n",
"# compile for task1\n",
"cmake --build build --config Debug --target task1\n",
"# run tests for task1\n",
"ctest --test-dir build -C Debug -R task1\n",
"```\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabe 2: Ein eigenes kleines C++-Programm (1 Punkt)\n",
"\n",
"Erstellen Sie ein lauffähiges *Ein-Dateien-Programm* das folgende Struktur aufweist:\n",
"\n",
"- Einbinden benötigter Header-Dateien aus der Standardbibliothek, z.B.:\n",
"\t```cpp\n",
"\t#include <iostream> // std::cout|endl\n",
"\t#include <...>\n",
"\t```\n",
"- Definition/Implementierung einer eigenen Funktion, z.B.:\n",
"\t```cpp\n",
"\tint sum(...){\n",
"\t ...\n",
"\t}\n",
"\t``` \n",
"- Definition/Implementierung einer `main`-Funktion (Einstiegspunkt für jedes lauffähige Programm), die Ihre selbest geschriebene Funktion verwendet und die berechneten Ergebnisse in der Konsole ausgibt, z.B.:\n",
"\t```cpp\n",
"\tint main(){\n",
"\t ...\n",
"\t auto res = sum(...)\t\n",
"\t std::cout << res << std::endl;\n",
"\t return 0;\n",
"\t}\n",
"\t``` "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"- Eine genaue Beschreibung und Anforderungen finden Sie in [task2.main.cpp](task2.main.cpp)\n",
"- Ihre Implementierung erfolgt ebenfalls in [task2.main.cpp](task2.main.cpp)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Kompilieren/Ausführen \n",
"\n",
"Mittels manueller Aufrufe (`gcc/g++/python`):\n",
"```shell\n",
"# prepare folder\n",
"mkdir build\n",
"# compile for task2\n",
"g++ -std=c++20 -g task2.main.cpp -o build/task2.exe\n",
"# run test (your output will be parsed when graded)\n",
"./build/task2.exe\n",
"```\n",
"\n",
"Alternativ mittels *CMake* (optional):\n",
"```shell\n",
"# prepare compilation\n",
"cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug\n",
"# compile for task2\n",
"cmake --build build --config Debug --target task2\n",
"# run tests for task2\n",
"ctest --test-dir build -C Debug -R task2\n",
"```"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabe 3: Einfache Funktionen ohne Verzweigungen (1 Punkt)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Implementieren Sie folgende Funktionen:\n",
"\n",
"```cpp\n",
"double add(double x, double y, double z);\n",
"double mul(double x, double y, double z);\n",
"double frac(double x, double y);\n",
"double mean(double x, double y, double z);\n",
"double squared(double x);\n",
"double cubed(double x);\n",
"double eval(double x, double a, double b, double c);\n",
"```"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"- Die vorgegebenen Deklarationen und eine genaue Beschreibung und Anforderungen finden Sie in [`task3.hpp`](task3.hpp)\n",
"- Ihre Implementierung erfolgt in [`task3.cpp`](task3.cpp)\n",
"- Die zugeordneten Tests finden Sie in [`task3.test.cpp`](task3.test.cpp)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Kompilieren/Ausführen \n",
"\n",
"Mittels manueller Aufrufe (`gcc/g++/python`):\n",
"```shell\n",
"# prepare folder\n",
"mkdir build\n",
"# compile for task3\n",
"g++ -std=c++20 -g task3.cpp task3.test.cpp -o build/task3.exe\n",
"# run test\n",
"./build/task3.exe\n",
"```\n",
"\n",
"Alternativ mittels *CMake* (optional):\n",
"```shell\n",
"# prepare compilation\n",
"cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug\n",
"# compile for task3\n",
"cmake --build build --config Debug --target task3\n",
"# run tests for task3\n",
"ctest --test-dir build -C Debug -R task3\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}