Sunteți pe pagina 1din 3

61. Write a program in Java to manipulate linked lists.

The input to the program will be a sequence of instructions of the following three categories: a) insert name age: create a node with item as the info field and insert into the current list. b) remove N : remove the Nth item from the list. c) print N : print the Nth item from the list. The name should be printed first and then the age with a space in between. d) stop : end of instructions Each of the instructions occurs on a different line. The list should always be maintained in sorted order in increasing order of age. If there is more than one person of same age, the order should be as in the input. You may assume that the input is valid and correct. While executing remove or print, if the list does not have enough elements, the command should be ignored. You may assume that the name is always a single word with no spaces within. The age will be a positive integer. Terminate each line output with a newline chacracter. Sample Input/Output: INPUT: insert sasi 40 insert srini 30 print 1 insert pradeep 35 remove 3 print 1 stop

SELF-ASSESSMENT ASSIGNMENT - 27 Removal of 'zero' Rows and Columns in a Matrix Problem Statement: -----------------Given an integer matrix of size, say, M x N, you have to write a

program to remove all the rows and columns consisting of all zeros. Your program must remove those rows and columns that consist of zero valued elements only. That is if all the elements in a row(column) are zeros, then remove that row(column)All other rows and columns should be output. Input Specification: -------------------The first line of input will have two integers, say, M and N. M specifies the number of rows in the matrix and N specifies the number of columns in the matrix. Hit return to Continue ..... This will be followed by M lines, each consisting of N integers. Note: Assume 1<=M<=10 and 1<=N<= 10. Also, you may assume that there is at least one nonzero element in the given matrix. Output Specification: --------------------The output should be the resulting matrix. Each row of output matrix should be terminated by a newline character. There should be at least one space between successive elements in each row.

Sample Input and Output: -----------------------Input: 44 1234 0000 5678 0003 Output: 1234 5678 0003 Input: 45 12035 00000

45069 78091 Output: 1235 4569 7891 35 12035 45069 78091 44 1235 0000 4569 7891

S-ar putea să vă placă și