c++ - Using a text file as input for a binary -
i'm trying test homework (knapsack problem) , it's getting repetitive entering these inputs every time recompile.
here's i've got:
will@will-mint ~/code/byun-sp15 $ g++ knapsack.cpp will@will-mint ~/code/byun-sp15 $ ./a.out please enter number of items: 3 please enter knapsack capacity: 10 enter weights , values of 3 items: item 1: 3 40 item 2: 2 10 item 3: 5 50 0 * 0 * 0 * 0 * 0 * 0 * 0 * 0 * 0 * 0 * 0 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 0 * 50 * 50 * 99 * 50 * 50 * 60 * 60 * 60 * 60 *
clearly table not correct, please not me there. no spoilers! put 3 10 3 40 2 10 5 50
in test.txt , tried following:
will@will-mint ~/code/byun-sp15 $ vim test.txt will@will-mint ~/code/byun-sp15 $ test.txt > ./a.out test.txt: command not found will@will-mint ~/code/byun-sp15 $ cat test.txt | ./a.out will@will-mint ~/code/byun-sp15 $ cat test.txt | ./a.out >> output.log will@will-mint ~/code/byun-sp15 $ vim output.log will@will-mint ~/code/byun-sp15 $ cat test.txt | ./a.out 2> output.log will@will-mint ~/code/byun-sp15 $ vim output.log will@will-mint ~/code/byun-sp15 $ ./a.out < test.txt will@will-mint ~/code/byun-sp15 $ cat test.txt | ./a.out > output.log will@will-mint ~/code/byun-sp15 $ vim output.log will@will-mint ~/code/byun-sp15 $ ./a.out << test.txt
none of worked. need bash-fu, how can use string of space-separated numbers in text file input a.out?
Comments
Post a Comment