Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# Import sys For args in sys.argv: fi=args fo=open(fi,”r+”) a=fo.readline() a=a.

ID: 3757588 • Letter: #

Question

#

Import sys

For args in sys.argv:

      fi=args

fo=open(fi,”r+”)

a=fo.readline()

a=a.strip()

b=fo.readline()

c=fo.readline()

c=c.strip()

ed=[]

for I in range(int(fo.readline())):

                t=fo.readline()

                t=t.strip()

                t=t.split()

                t=list(t)

                ed.append(t)

#print ed

Strtst=fo.readline()

Strtst=strtst.strip()

fs=fo.readline()

fs=fs.strip()

fs=fs.split()

fs=list(fs)

del(fs[0])

while(1):

             foundexp=0

             curspos=0

            curst=strtst

            test=fo.readline()

            test=test.strip()

            print(test)

            if(test==””):

                   break

            while(1):

                    for I in ed:

                    # print i[0],curst

                       If(int(i[0])==int(curst)):

                                      If(i[2]==test{curspos:curspos:curspos+len(i[2])]);

                                       Foundexp=1

                                       Curst=i[1]

                                        Curspos=curspos+len(i[2])

       #                        print “curspos=”curspos

      #                         print”curst=”.curst

                                 break

                          else:

                                        foundexp=0

                     else:

                                 foundexp=0

#      print curspos,len(test),curst,fs

If(foundexp==0):

              Print “REJECT”

              break

else(curspos==len(test) and (curst in fs)):

              print “ACCEPT”

              break

else:

              continue

Can u convert this code into c++ or java

Explanation / Answer

#include #include #include #include std::vector fabricate(std::vector & v) { std::vector res(v.size() + 1, NULL); for (std::size_t i = 0; i != v.size(); ++i) { res[i] = &v[i][0]; } return res; } std::vector args_vector((std::istream_iterator(std::cin)), std::istream_iterator()); std::vector argv_vector = fabricate(args_vector); int main(int argc, char * argv[]) { argc = args_vector.size(); argv = argv_vector.data(); // ... }