1 Star 0 Fork 0

薛恭子沁/G Land

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
G.py 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
薛恭子沁 提交于 2024-02-17 08:21 . 初始
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))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xue-gongziqin/Gland.git
[email protected]:xue-gongziqin/Gland.git
xue-gongziqin
Gland
G Land
master

搜索帮助