diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-01-06 17:32:18 +0100 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-01-06 17:32:18 +0100 |
| commit | 78dd0d29ea64546fd1fa8f7ddbdd2b52888c5f91 (patch) | |
| tree | a6233cfc51420bb83db4463614e5c2001b941180 | |
| parent | bc73791d5f798427671e5978b4d149e66bded8ac (diff) | |
Deleting roman numerals. I mean seriously ;)
| -rw-r--r-- | sonstiges/Roman.cpp | 34 | ||||
| -rw-r--r-- | sonstiges/sonstiges.tex | 3 | ||||
| -rw-r--r-- | tcr.pdf | bin | 233232 -> 230265 bytes |
3 files changed, 0 insertions, 37 deletions
diff --git a/sonstiges/Roman.cpp b/sonstiges/Roman.cpp deleted file mode 100644 index c5ead54..0000000 --- a/sonstiges/Roman.cpp +++ /dev/null @@ -1,34 +0,0 @@ -map<char,int> m; map<int,char> o; -int num[7] = {1000,500,100,50,10,5,1}; - -void buildMap() { - m['M'] = 1000; m['D'] = 500; m['C'] = 100; m['L'] = 50; m['X'] = 10; m['V'] = 5; m['I'] = 1; m[' '] = 0; - o[1000] = 'M'; o[500] = 'D'; o[100] = 'C'; o[50] = 'L'; o[10] = 'X'; o[5] = 'V'; o[1] = 'I'; -} - -int convertToInt(string &s) { - int res = m[s[0]]; - for(int i = 1; i < s.size(); i++) { - if(m[s[i-1]] < m[s[i]]) - res -= 2*m[s[i-1]]; - res += m[s[i]]; - } - return res; -} - -string convertToRoman(int n) { - string roman = ""; - for(int i = 0; i < 7; i++) { - while(n >= num[i]) { - roman += o[num[i]]; - n -= num[i]; - } - } - int pos = roman.find("CCCC"); if(pos != string::npos) roman.replace(pos,4,"CD"); - pos = roman.find("XXXX"); if(pos != string::npos) roman.replace(pos,4,"XL"); - pos = roman.find("IIII"); if(pos != string::npos) roman.replace(pos,4,"IV"); - pos = roman.find("DCD"); if(pos != string::npos) roman.replace(pos,3,"CM"); - pos = roman.find("LXL"); if(pos != string::npos) roman.replace(pos,3,"XC"); - pos = roman.find("VIV"); if(pos != string::npos) roman.replace(pos,3,"IX"); - return roman; -} diff --git a/sonstiges/sonstiges.tex b/sonstiges/sonstiges.tex index 64bc206..1f111bc 100644 --- a/sonstiges/sonstiges.tex +++ b/sonstiges/sonstiges.tex @@ -20,9 +20,6 @@ Wenn die Eingabe aus einem kleinen Intervall $\left[0, n\right)$ stammt ist Buck \subsection{Bit Operations} \lstinputlisting{sonstiges/bitOps.cpp} -\subsection{Roman-Literal-Converting} -\lstinputlisting{sonstiges/Roman.cpp} - \subsection{Josephus-Problem} $n$ Personen im Kreis, jeder $k$-te wird erschossen. \begin{description} Binary files differ |
