. 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 | | | |
------------------------------------
Answers were Sorted based on User's Feedback
Answer / indrasen singh
follow these steps..
a) Create 10 by 10 matrix of char array and fill with '|'
b) Now in a loop check your first matrx whether it have alphabet character if found then insert it into the new matrix in the desired position....
char str1[10][10] // suppose it contains your data
char str2[10][10] //it store result
int i,j;
for(i=0;i<10;i++)
for(j=0;j<10;j++)
str2[j]='|';
int charfound;
for(i=0;i<10;i++)
{
charfound=0;
for(j=0;j<10;j++)
{
if(isalpha(str1[j]))
{
charfound++;
str2[((charfound*2)-1)]=str1[j];
}
}
}
Is This Answer Correct ? | 1 Yes | 5 No |
Answer / 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 |
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.
A Binary no. is given, we hav to find it's decimal equivalent.
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
0 Answers Jomo Kenyatta University,
. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
How do I store linked list datas into an array?
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
Definition of priority queue was given. We have to implement the priority queue using array of pointers with the priorities given in the range 1..n. The array could be accessed using the variable top. The list corresponding to the array elements contains the items having the priority as the array index. Adding an item would require changing the value of top if it has higher priority than top. Extracting an item would require deleting the first element from the corresponding queue. The following class was given: class PriorityQueue { int *Data[100]; int top; public: void put(int item, int priority); // inserts the item with the given priority. int get(int priority); // extract the element with the given priority. int count(); // returns the total elements in the priority queue. int isEmpty(); // check whether the priority queue is empty or not. }; We had to implement all these class functions.
0 Answers Nagarro, Wollega University,
Code for Easily Using Hash Table?
A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E
write a program in c++ to scramble a bmp image file using a scramble key 0x7c and an XOR logic. print out the original image, the scrambled image and the program. Note: the first 24bytes of a bmp file contain the header information of the file.