Strength Reduction

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

PROGRAM:

n=int(input("Enter the number of quadarples:"))

b=[list(map(str,input().split())) for i in range(n)]

a=[]

k=0

for i in range(n):

opr=b[i][0]

op1=b[i][1]

op2=b[i][2]

res=b[i][3]

if(opr=='^'):

k=int(op2)

x=['*',op1,op1,res]

a.append(x)

for j in range(0,k-2):

x=['*',op1,res,res]

a.append(x)

elif(opr=='*'):

k=int(op2)

x=['+',op1,op1,res]

a.append(x)

for j in range(0,k-2):

x=['+',op1,res,res]

a.append(x)

Page No.:
else:

a.append(b[i])

print("after strength reduction:")

for i in a:

for j in i:

print(j,end=' ')

print('',sep='\n')

OUTPUT:

RESULT:

Page No.:

You might also like