diff --git a/test/5/1.py b/test/5/1.py new file mode 100644 index 0000000..bcd353e --- /dev/null +++ b/test/5/1.py @@ -0,0 +1,4 @@ +n = int(input()) +print(bin(n)[2:]) +print(oct(n)[2:]) +print(hex(n)[2:]) \ No newline at end of file diff --git a/test/5/2.py b/test/5/2.py new file mode 100644 index 0000000..af325c6 --- /dev/null +++ b/test/5/2.py @@ -0,0 +1,2 @@ +for i in range(33, 127): + print(str(i) + " " + chr(i)) \ No newline at end of file diff --git a/test/5/3.py b/test/5/3.py new file mode 100644 index 0000000..5e14b38 --- /dev/null +++ b/test/5/3.py @@ -0,0 +1,7 @@ +s = input() +print(str(s.encode("GB2312"))[2:-1]) +print(str(s.encode("GBK"))[2:-1]) +print(str(s.encode("GB18030"))[2:-1]) +print(str(s.encode("UTF-8"))[2:-1]) +print(str(s.encode("UTF-16-BE"))[2:-1]) +print(str(s.encode("UTF-16-LE"))[2:-1]) \ No newline at end of file diff --git a/test/5/4.py b/test/5/4.py new file mode 100644 index 0000000..66d6387 --- /dev/null +++ b/test/5/4.py @@ -0,0 +1,6 @@ +s = input() +for i in s: + if (ord(i) >= ord('a') and ord(i) <= ord('z')): + print(chr(ord(i) - 32), end="") + else: + print(i, end="") diff --git a/test/5/5.py b/test/5/5.py new file mode 100644 index 0000000..efe6f19 --- /dev/null +++ b/test/5/5.py @@ -0,0 +1,10 @@ +def b(x): + s = "" + while (x): + s += str(x % 2) + x //= 2 + return s[::-1] + + +a = int(input()) +print(b(a)) \ No newline at end of file diff --git a/test/5/6,7.py b/test/5/6,7.py new file mode 100644 index 0000000..7502673 --- /dev/null +++ b/test/5/6,7.py @@ -0,0 +1,30 @@ +def b(x): + if (x == 0): + return "0" + s = "" + while (x): + s += str(x % 2) + x //= 2 + return s[::-1] + + +def binx(x): + x -= int(x) + if (x == 0): + return "" + binn = "." + while x: + x *= 2 + if x >= 1: + binn += "1" + else: + binn += "0" + x -= int(x) + if (len(binn) >= 9): + return binn + return binn + + +a = float(input()) +print(b(int(a)), end="") +print(binx(a)) \ No newline at end of file