xiti2:
import sys
import stdio
import stdarray
import math
import random
n = int(sys.argv[1])
a = stdarray.create1D(n,0.0)
b = stdarray.create1D(n,0.0)
for i in range(n):
a[i] = random.randrange(1,10)
b[i] = random.randrange(1,10)
stdio.writeln(a)
stdio.writeln(b)
c = 0
for i in range(n):
c += (a[i]-b[i])*(a[i]-b[i])
stdio.writeln(c)
stdio.writeln(c)
c = math.sqrt(c)
stdio.writeln(c)
xiti3:
import sys
import stdio
import random
import stdarray
n = int(sys.argv[1])
a = stdarray.create1D(n,0.0)
for i in range(n):
a[i] = random.randrange(1,10)
stdio.writeln(a)
for i in range(n):
for j in range(i+1,n):
if a[i]<a[j]:
temp = a[i]
a[i] = a[j]
a[j] = temp
stdio.writeln(a)
xiti5:
import stdio
import sys
import stdarray
import random
m = int(sys.argv[1])
n = int(sys.argv[2])
a = stdarray.create2D(m,n,0.0)
for i in range(m):
for j in range(n):
a[i][j] = random.choice([True,False])
stdio.writeln(a)
for i in range(m):
for j in range(n):
if(a[i][j] == True):
a[i][j] = '*'
else:
a[i][j] = ' '
stdio.writeln(a)
xiti16:
import sys
import stdio
import stdarray
import random
m = random.randrange(1,5)
n = random.randrange(1,5)
p = random.randrange(1,5)
a = stdarray.create2D(m,n,0.0)
b = stdarray.create2D(n,p,0.0)
c = stdarray.create2D(m,p,0.0)
for i in range(m):
for j in range(n):
a[i][j] = random.randrange(1,10)
for i in range(n):
for j in range(p):
b[i][j] = random.randrange(1,10)
stdio.writeln(a)
stdio.writeln(b)
for i in range(m):
for j in range(n):
for k in range(p):
c[i][k] += a[i][j]*b[j][k]
stdio.writeln(c)
stdio.writeln(c)