Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

to read intgers into program  RSS feed

 
chintan chainani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hye, i'm not quite able to figure this out, if someone can help by showing some example code :
i wanna enter integers into the variables from console after running program,am unable to do it with readInt(), also the input speciication is a space between integers. which are then taken as row and column of an int array.

p.s :pl reply ASAP, have been sitting on this too long.
 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using main method in your program?
If yes,then you can use following code :-

Does this help?
 
chintan chainani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks jitesh that worked fine on the command line, but what i was looking for is the how does the program with main() , prompt user to enter the numbers, after program is run.
let me just print the whole problem : (maybe this will belong to java beginner,but since you replied I will just type it here..thanks)
REMOVAL OF 'ZERO ROWS AND COLUMNS IN A MATRIX.
given an integer matrix of size, say, M x N, to write a program to remove all the rows and columns consisting of all zeroes.
INPUT SPECIFICATION:
the first line of input will have 2 integers , say M and N, separated by a space, specifying number of row and column in matrix.
This will be followed by M LINES, EACH consisting of N integers.
assuming M and N can be between 1 and 10 only.

/*now i have got the logic for the program but am a little (or majorly)confused with input classes . So if you or someone could please help me with this ....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!