. Remove all the blank spaces between
character.Matrix is of 10* 10.
eg: INPUT
------------------------------------
| N | A | | V | |T
-------------------------------------
| |G | U | |P |
--------------------------------------
|T | | | A | |
------------------------------------
OUTPUT:
------------------------------------
| N | A | V | T | |
-------------------------------------
|G |U | P | | |
--------------------------------------
|T | A | | | |
------------------------------------

Answer Posted / kiran

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package removespacesfrommatrix;

/**
*
* @author Sunshine
*/
public class RemoveSpacesFromMatrix {

void print(char[][] matrix) {
char temp;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (matrix[i][j] != ' ') {
System.out.println(matrix[i][j]);
} else {
temp = matrix[i][j + 1];
matrix[i][j] = temp;
matrix[i][j + 1] = ' ';
System.out.println(matrix[i][j]);
}
}
}
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
char[][] matrix;
matrix = new char[][]{{'a', 'b', ' ', 'c'}, {' ', 'd', ' ', 'f'}, {' ', ' ', 'x', 'y'}, {'m', 'n', 'o', 'p'}};
RemoveSpacesFromMatrix r = new RemoveSpacesFromMatrix();
r.print(matrix);
}
}

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)

2125


output for printf("printf");

1985


Code for Easily Using Hash Table?

2391


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

3440


A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect

2407






how to diplay a external image of output on winxp by using c & c++,

2938


develop a program to calculate and print body mass index for 200 employees

2216


write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation

2407


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

2152


what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

2068


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

7041


Write a simple encryption program using string function which apply the substitution method.

5538


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

7344


write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150

3266


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2065