Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
53 changes: 50 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,55 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true
}
"workbench.statusBar.visible": true,
"files.associations": {
"limits": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"new": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
}
}
24 changes: 22 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,30 @@
"problemMatcher": [
"$gcc"
],
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: g++ Aktive Datei kompilieren",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
},
"detail": "Vom Debugger generierte Aufgabe."
}
]
}
2 changes: 1 addition & 1 deletion loesungen/04_04/main_uebung_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float berechnung(float parameter_1, float parameter_2)
{
float erhoeter_param = parameter_2 + 2;

float resultat = parameter_1 * parameter_2;
float resultat = parameter_1 * erhoeter_param;

return resultat;
}
Expand Down
Binary file added src/main
Binary file not shown.
58 changes: 58 additions & 0 deletions src/main_02_Variablen_und_Basistypen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
#include <limits>

int main()
{
// Ich bin eine Notiz.
std::cout << "Hallo, mein Name ist Chris." << std::endl;
int imin = std::numeric_limits<int>::min(); // minimum value
int imax = std::numeric_limits<int>::max();

std::cout << "Min int" << imin << std::endl;
std::cout << "Max int" << imax << std::endl;

int fmin = std::numeric_limits<float>::min(); // minimum value
int fmax = std::numeric_limits<float>::max();

std::cout << "Min float" << fmin << std::endl;
std::cout << "Max float" << fmax << std::endl;

int meine_erste_int_variable = 4;
int meine_zweite_int_variable = 2;
int mein_int_ergebnis = meine_erste_int_variable + meine_zweite_int_variable;

std::cout << "Int Ergebnis: " << mein_int_ergebnis << std::endl;

float meine_erste_float_variable = 4.8;
float meine_zweite_float_variable = -2.9;
float mein_float_ergebnis = meine_erste_float_variable + meine_zweite_float_variable;

std::cout << "Float Ergebnis: " << mein_float_ergebnis << std::endl;

double meine_erste_double_variable = 4.8;
double meine_zweite_double_variable = -2.9;
double mein_double_ergebnis = meine_erste_double_variable + meine_zweite_double_variable;

std::cout << "Double Ergebnis: " << mein_double_ergebnis << std::endl;

bool wahre_variable = true;
bool falsche_variable = false;

std::cout << "Wahre Variable: " << wahre_variable << std::endl;
std::cout << "Falsche Variable: " << falsche_variable << std::endl;

char mein_zeichen = 'x';

std::cout << "Meine Char Variable: " << mein_zeichen << std::endl;

int mein_array [7] = {};

std::cout << "Mein Array an Index 3: " << mein_array[3] << std::endl;

mein_array[4] = -9;

std::cout << "Mein Array an Index 3: " << mein_array[3] << std::endl;
std::cout << "Mein Array an Index 4: " << mein_array[4] << std::endl;

return 0;
}
Binary file added src/main_03_07
Binary file not shown.
28 changes: 28 additions & 0 deletions src/main_03_07.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>

int main()
{
int array[5] = {};

for(int index = 0; index < 5; index++){
array[index] = 3 * index;
if (array[index] >= 6)
{
std::cout << "Array[" << index << "] = " << array[index] << std::endl;
}
}

int variable_1 = 10;
int variable_2 = 2;

while (variable_1 >= variable_2)
{
variable_1 += 1;
variable_2 += 2;
if (variable_2 > variable_1)
{
std::cout << "Variable 1: " << variable_1 << "; Variable 2: " << variable_2 << std::endl;
}
}
return 0;
}
Binary file added src/main_04_04
Binary file not shown.
49 changes: 49 additions & 0 deletions src/main_04_04.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <iostream>

void ausgabeMeinArray(int* array, int array_size)
{
for (int index = 0; index < array_size; index++)
{
std::cout << "Array[" << index << "]=" << array[index] << std::endl;
}
}

float multiply_floaty_plus2(float par1, float par2){
float product=0;
product=par1*(par2+2);
return product;
}

bool test_3_var_smaller(int var1, int var2, int var3)
{
bool result;
if((var1<var2)&&(var2<var3)){
result=true;
}else{
result=false;
}

return result;
}

int main()
{
int array_size=5;
int array[array_size] = {1, 2, 3, 4, 5};
ausgabeMeinArray(array, array_size);

float a = 2.0;
float b = 3.0;
float product = 0;

product = multiply_floaty_plus2(b,a);
std::cout<< product << std::endl;

int var1=1;
int var2=2;
int var3=1;

std::cout<< "Test ob Var1 < Var2 < Var3: " << test_3_var_smaller(var1, var2, var3) << std::endl;

return 0;
}
Binary file added src/main_05_05
Binary file not shown.
98 changes: 98 additions & 0 deletions src/main_05_05.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include <iostream>

std::string mapping(int choosen)
{
std::string word = "";
switch (choosen)
{
case 1:
word="Schere";
break;
case 2:
word="Stein";
break;
case 3:
word="Papier";
break;
}
return word;
}

int main()
{
bool weiterspielen = true;

while (weiterspielen==true)
{

int comp=0;
int usr=0;
std::string winner={};



while((usr<1)||(usr>3))
{
std::cout << "Wählen Sie zwischen:\n Schere(1)\n Stein(2)\n Papier(3):" << std::endl;
std::cin>> usr;

if ((usr < 1)
|| (usr > 3))
std::cout << "Falsche Eingabe!"<< std::endl;
}

comp = rand() %3 + 1;

/* usr comp result
1 1 equal
1 2 comp
1 3 usr
2 1 usr
2 2 equal
2 3 comp
3 1 comp
3 2 usr
3 3 equal
*/
if(usr==comp)
{
winner="Niemand (Unentschieden)";
}else if((usr == 1 && comp == 3)||
(usr == 2 && comp == 1)||
(usr == 3 && comp == 2)){
winner="der Spieler";
}
else{
winner="der Computer";
}

std::cout<< "Der Spieler hat " << mapping(usr) << " ausgewählt." << std::endl;
std::cout << "Der Computer hat " << mapping(comp) << " ausgewählt." << std::endl;
std::cout << "Es gewinnt " << winner << std::endl;

char choice=NULL;
weiterspielen = NULL;
std::cout << "Möchten Sie noch einmal spielen? (Drücken Sie 'J' für Ja oder 'N' für Nein): ";
while (choice != 'N' && choice != 'n' && choice != 'J' && choice != 'j')
{
std::cin >> choice;

if (choice == 'N' || choice == 'n')
{
std::cout << "Das Spiel wird beendet." << std::endl;
weiterspielen=false;
}
else if(choice == 'J' || choice == 'j')
{

std::cout << "Sie spielen noch einmal" << std::endl;
weiterspielen=true;
// ...
}
else{
weiterspielen=NULL;
}
}
}
return 0;
}
Binary file added src/main_06_05
Binary file not shown.
Loading