I plan开发者_JAVA百科 on doing the Code Jam competition next year. The problem is (something that I can't find anywhere) how do I set up my code to accept input and return an output?
I'm just confused as to how I am supposed to handle everything, say for example that I have to add 1 to the input and make the result the output, how would I handle the input/output?
I plan on using LUA. Thanks if you can. I think a code example would be best!
Go to http://www.go-hero.net/jam/11/solutions and choose the problem and the language. You'll find all the examples you need there. Including Lua ones.
http://www.go-hero.net/jam/ On this page you can see source code for every contestant. You should be able to answer your question from it.
You can either do I/O on files or on stdin/stdout. It doesn't matter. I've seen examples that used files and examples that used stdin/stdout.
In Python say, you could write
import fileinput
f = fileinput.input()
Then call the script from the shell like this
gorosort.py A-small-practice.in
To save the output to a file
gorosort.py A-small-practice.in > A-small-practice.out
精彩评论