![](/img/trans.png)
[英]Trigonometric Functions: How do I write Sine and Cosine function's code without using `math` module?
[英]How I write this code without functions
这是真实的代码,我想编写没有功能的代码。
import sys
from fractions import gcd
n = int(sys.argv[1])
for i in range(n):
for j in range(n):
GCD = gcd(i, j)
if GCD == 1:
sys.stdout.write("* ")
else:
sys.stdout.write(" ")
print
该代码的输出是; 代码和我尝试过的代码。 但是它不能像上面的代码那样工作。
import sys
n = int(sys.argv[1])
for x in range(n):
for y in range(n):
while y != 0:
temp = y
y = x % y
x = temp
GCD = x
if GCD == 1:
sys.stdout.write("* ")
else:
sys.stdout.write(" ")
print
而我的代码的输出是; 我的代码我该怎么做,就像没有功能的第一个代码的输出一样。
编辑:我不知道sys.stdout.write实际上是内置功能。 所以我会解释。 就像没有换行的打印功能。
您可以使用此:
import sys
n = int(sys.argv[1])
for i in range(n):
for j in range(n):
a,b =i,j
while b:
a, b = b, a%b
GCD = a
if GCD == 1:
sys.stdout.write("* ")
else:
sys.stdout.write(" ")
print
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.