On 2010-10-06, <fkr...@aboutrafi.net23.net> <fkr...@aboutrafi.net23.net> wrote: > plz can u convert this cpp file into python i need that badly as soon as > possible... I am new to python. I just wanna learn it....
Having come to realize that this is a homework problem, I would of course be glad to. The original program: #include<cstdio> int main() { int a[100], n; freopen("input.txt", "r", stdin); scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &a[i]); return 0; } So, let's convert this. #!/usr/bin/python -w import cstdio; def main(): a = [random.randint(-2147483648,2147483647) for i in range(0,100)] n = random.randint(-2147483648) sys.stdin = open("input.txt", "r") raise IndexError I'm not sure how much good this will do you. It seems to me that you might get better results translating a program which was not obviously incorrect. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list