代码拉取完成,页面将自动刷新
import setting
import numpy as np
from os import system
from time import sleep
from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_histogram
def cout(text):
print(text)
def icin(number):
try:
a = int(input(number))
return a
except:
print('not a number')
raise ValueError
def scin(text):
try:
a = str(input(text))
return a
except:
print('not a text')
raise ValueError
def cmd(textline):
try:
system(textline)
except:
print('I can\'t do that')
raise SystemError
def stop(time):
try:
sleep(time)
except:
print('can not stop with a text')
raise ValueError
def abc(number):
try:
answer = number - number * 2
return answer
except:
print('not a number')
raise ValueError
def JM(text, n_qubits=3):
# 将明文字符串转换为数字矩阵A
A = [ord(c) for c in text]
# 创建量子电路
qc = QuantumCircuit(n_qubits)
# 使用量子计算机对数字矩阵A进行一次或多次操作
for i in range(len(A)):
if i % 2 == 0:
qc.h(i)
else:
qc.cx(i, (i + 1) % n_qubits)
# 将操作后的量子态转换回数字矩阵B
B = qc.density_matrix(range(n_qubits)).toarray()
# 对数字矩阵B进行一次或多次操作
for i in range(len(B)):
if i % 2 == 0:
qc.h(i)
else:
qc.cx(i, (i + 1) % n_qubits)
# 将最终结果矩阵转换回字符串
encrypted_text = ''.join([chr(int(round(b))) for b in B])
return encrypted_text
def biggest(*list):
try:
turn = 0
for temp in list:
if temp > trun:
turn = temp
except:
print('not a list of number')
raise ValueError
return turn
def smallest(*list):
try:
turn = 0
for temp in list:
if temp < trun:
turn = temp
except:
print('not a list of number')
raise ValueError
return turn
cout(biggest(12, 13))
cout(smallest(12, 13))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。