diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog1/Prakt2/prg1p2_2 | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog1/Prakt2/prg1p2_2')
| -rw-r--r-- | Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.cpp | 86 | ||||
| -rw-r--r-- | Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsp | 100 | ||||
| -rw-r--r-- | Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsw | 29 |
3 files changed, 215 insertions, 0 deletions
diff --git a/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.cpp b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.cpp new file mode 100644 index 0000000..1ac93e1 --- /dev/null +++ b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.cpp @@ -0,0 +1,86 @@ +// Programmieren 1, Praktikum 2, Aufgabe 2
+// Sven Eisenhauer
+// 29.10.2004
+//
+// file: prg1p2_2.cpp
+//
+// purpose: convert bin to dec numbers or dec numbers to bin
+// 10 digits mean 2exp9 to 2exp0
+//
+#include <iostream>
+#include <cmath>
+using std::cin;
+using std::cout;
+using std::endl;
+
+int main()
+{
+ const iBit=10; //define how large the binary output should be.
+
+ int iMode;
+ int iBin=0;
+ int iActualFactor=0;
+ int iDec=0;
+ int iCounter=0;
+ int iCounter2=0;
+ //int iBinOut[iBit];
+ int iBinOut=0;
+
+
+ do
+ {
+ system("cls");
+ cout << "Please select Converter:\n1) Bin -> Dec\n2) Dec -> Bin\n\n0) End\n\n"
+ "Your selection: ";
+ cin >> iMode;
+ switch (iMode) {
+ case 1:
+ cout << "\nPlease enter a binary number (max 10 characters): ";
+ cin >> iBin;
+ for (iCounter = 9;iCounter>=0;iCounter--)
+ {
+ iActualFactor=iBin/pow(10,iCounter);
+ iDec+=(iActualFactor * static_cast <int> (pow(2,iCounter)));
+ iBin=iBin%static_cast <int>(pow(10,iCounter));
+ }
+ cout << "\nDecimal: " << iDec;
+ cout << endl;
+ system ("pause");
+ break; // end bin2dec
+ case 2://dec2bin
+ cout << "\nPlease enter a decimal number: ";
+ cin >> iDec;
+ cout << "\n"<<iBit<<"-bit Integer is: ";
+ /* // fill the array
+ for (iCounter=iBit-1;iCounter>=0;iCounter--)
+ {
+ iBinOut[iCounter]=iDec%2;
+ iDec=iDec/2;
+ }
+ // print array in reverse order
+ for (iCounter=0;iCounter<=iBit-1;iCounter++)
+ {
+ cout << iBinOut[iCounter];
+ if (0==((iCounter+1)%4)) // space separator after 4 bit
+ cout <<" ";
+ }
+ */
+ iBinOut=0;
+ for (iCounter2=iBit;iCounter2>=0;iCounter2--)
+ {
+ iBin=iDec%2;
+ iDec=iDec/2;
+ iBinOut += iBin * static_cast <int> (pow(10,iBit-iCounter2));
+ }
+ cout << iBinOut << endl;
+ system ("pause");
+ break; // end dec2bin
+ case 0: // end selected... we are leaving...
+ break;
+ default: // wrong selection
+ cout << "\n !! No functon selected !!";
+ } // end switch
+ } // end while
+ while (iMode != 0);
+ return 0; // so far, we are ok
+}// end main
\ No newline at end of file diff --git a/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsp b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsp new file mode 100644 index 0000000..63ba0bc --- /dev/null +++ b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="prg1p2_2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=prg1p2_2 - Win32 Debug
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE
+!MESSAGE NMAKE /f "prg1p2_2.mak".
+!MESSAGE
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE
+!MESSAGE NMAKE /f "prg1p2_2.mak" CFG="prg1p2_2 - Win32 Debug"
+!MESSAGE
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE
+!MESSAGE "prg1p2_2 - Win32 Release" (basierend auf "Win32 (x86) Console Application")
+!MESSAGE "prg1p2_2 - Win32 Debug" (basierend auf "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "prg1p2_2 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "prg1p2_2 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "prg1p2_2 - Win32 Release"
+# Name "prg1p2_2 - Win32 Debug"
+# Begin Group "Quellcodedateien"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\prg1p2_2.cpp
+# End Source File
+# End Group
+# Begin Group "Header-Dateien"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Ressourcendateien"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsw b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsw new file mode 100644 index 0000000..8fa2314 --- /dev/null +++ b/Bachelor/Prog1/Prakt2/prg1p2_2/prg1p2_2.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
+
+###############################################################################
+
+Project: "prg1p2_2"=.\prg1p2_2.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
|
