C++ :: Transpose Matrix Array Manipulation
Jan 3, 2013
Array Manipulation - Transpose of a Square Matrix: This program reads a matrix (two dimensional array), displays its contents, transposes it and then displays the transposed matrix. And here's the code
Code:
#include <iostream.h>
const int arraySize = 3;
void readMatrix(int arr[][arraySize]);
void displayMatrix(int a[][arraySize]);
void transposeMatrix(int a[][arraySize]);
[Code] ....
When I compile the program it says 'mail' must return 'int' I think everything is right...
View 2 Replies
ADVERTISEMENT
Mar 24, 2013
I want to find transpos of square matrix.but my program does not run complete.
Code:
#include<iostream>
using namespace std;
const int size=3;
void read(int a[size][size])
[Code] .....
View 2 Replies
View Related
Jan 29, 2013
I wrote a template class for Matrix manipulation. The compiler cannot compile the source and complains
Matrix.h:144:41: error: expected initializer before ‘const’
What is the problem of the code enclosed below?
#ifndef MATRIX_H
#define MATRIX_H
/**
* @file Matrix.h
*The Matrix template class written for simplify the matrix manipulation.
*/
#include <cassert>
using namespace std;
template<typename T>
class Matrix {
int rows,cols;
[Code] .....
View 6 Replies
View Related
Mar 25, 2014
Basically i need to encrypt a message into ascii values & i also need to allow the user type some ascii values thus decrypting the values into characters that are placed within the code.
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;
#define Q 2000
void main(){
char array1[Q]={"A gentle, dull flickering flame, burns in the marble hearth. Its dim light scarcely illuminates the small, cozy room with its quiet elegance. The dismal light plays softly causing shadows over the solitary figure of a wooden desk at which Allen was roaming through his memories. Thinking back in the past where he once had a friendship which was out righteously incredible. She was the girl of his dreams, in a way which she had everything he had ever sought out in a beautiful and clever girl. Most of all she had his heart. Her style was incredible in the way the outfits she would wear would match perfectly giving a deep vibrant lively feeling."};
int S[Q];
char S1[Q];
int x;
int i;
char e, d;
cin>>x;
if(x=d){
cin>>Q;
for(i=0;i<array1[Q];i++)
cout << S[i]<<endl;
for(i=0;i<array1[Q];i++)
cout << S[i]<<endl;
}
View 18 Replies
View Related
Apr 26, 2013
Consider a program that simulates a card game, with multiple player hands and a deck to draw from. Each hand can use an array to represent the cards it contains; sometimes it is useful to also declare an additional variable for each hand (or deck) indicating exactly how many cards are present.
1) Describe a simple function that would manipulate both the array representing a hand and the number indicating the size of the hand.
2) Describe a simple function that might be able to manipulate the array without referring to the hand size variable at all.
3) Generally, if the array was passed as a parameter to a function, how often would the hand size be included as a parameter?
View 2 Replies
View Related
Jun 4, 2013
#include <stdio.h>
#include <stdlib.h>
int size_b_row1;
int size_b_col1;
int main(void) {
double C[4][4] = {{1,3,5,2},{7,6,2,2},{1,2,7,3},{2,3,5,3}};
double TC[4][4];
transpose(C, TC);
[Code] ......
View 2 Replies
View Related
Mar 3, 2013
I am having trouble understanding the mantissa of a floating point number. I have divided up the floating point number into the sign bit, the exponent and the mantissa, I have found the exponent, but I am not sure what to do with the mantissa? From what I have gathered so far i divide the mantissa by ten until I get a number between 1 and 10. after that i convert the number into a decimal with everything after the decimal point (or radix) being a fractional number. But when I do that on paper I dont get my intended number. How do i put the exponent and mantissa together to make a decimal from my floating point?
ex. input is 00111010000111111111011000001000
sign is 0
exponent is 01110100 which is 64+32+16+4-127=-11
mantissa is 00111111111011000001000 which would be 1.11111111011000001
When i convert that i get 1.99756622314 i dont know what to do with the -11 exponent and the answer i want is 6.1e-4
View 1 Replies
View Related
Jan 20, 2013
I'm trying to find the errors in my emulation of VGA VRAM concerning graphics modes.
(I'm testing it by doing plotting of all colors from x=0 to x=xsize-1 (where the color is relative, so 0=0 and xsize-1=maxcolor (in the case of 16 colors it's 15, etc.)))
VRAM Graphics management:
#include "headers/types.h" //Basic type support!
#include "headers/hardware/ports.h" //Basic PORT compatibility!
#include "headers/hardware/vga.h" //VGA data!
#include "headers/mmu/mmu.h" //For CPU passtrough!
#include "headers/hardware/vga_screen/vga_displaygeneration_crtcontroller.h" //For virtual width in bytes within VRAM!
[Code] .....
View 1 Replies
View Related
Dec 10, 2013
I need a large string vector for file content manipulation.
v1.max_size() gives me 153 391 689.
But if I make a test by looping a vector pushing back strings it crashes around 16 - 26 000 000 though I still have a lot of ram (1GB left).
How come and why isn't vector size limited by ram instead?
View 11 Replies
View Related
Mar 24, 2013
Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.
Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;
[Code] ....
View 6 Replies
View Related
Feb 15, 2012
I have the following function I would like to convert to work with std:string. I don't understand QT strings at all.
Code:
void FromHexString(const QString &hexText, void* pData, int dataSize) {
for (int i = 0; i < hexText.length(); ++i) {
bool ok = false;
((uint8_t*)pData)[ i ] = hexText.mid( 2*i, 2 ).toInt( &ok, 16 );
}
}
View 1 Replies
View Related
Dec 5, 2012
I work on a system that communicates with other systems via messages. Those messages are defined in a spec and every word must be exactly as defined. To accomplish this Ada allows me to define the fields of my record to specific words in memory.
Code:
word = 4;
type Msg_Type1 is record
x: Some_Type;
y: Another_Type;
z: Another_Type;
end record;
[Code] ....
View 5 Replies
View Related
Mar 27, 2013
i want to know how i can solve this question? do i need to create a class or write the program codes.
View 12 Replies
View Related
Sep 24, 2013
1. Input an dimension and elements of an array from the keyboard. Count the odd elements of an array and that number join to variable K, then sort the last K elements in decreasing order.
Code:
#include <stdio.h>
main ()
{
int A[100], i, n, j, K = 0;
printf ("Type in the dimension of an array:
");
scanf ("%d", &n);
[Code]....
View 7 Replies
View Related
Jan 12, 2015
Q.Write a program using user-defined function which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format: If the array is 1,2,3,4,5,6, the resultant 2D array is
1 2 3 4 5 6
1 2 3 4 5 0
1 2 3 4 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
Ans.
#include<iostream>
using namespace std;
int two_print(int x, int one[999]) {
int two[999][999], q=x, z=x;
for(int k=0; k<x; k++) {
q--;
[code].....
View 2 Replies
View Related
Jun 1, 2014
I just want to know the code of the program: Write code to accept matrix as aurgument and display its multiplication matrix which return its multiplication matrix.
View 1 Replies
View Related
Jun 3, 2013
I'm trying to copy my array 'block' to a 'dummy' 3D matrix so I can take out some arbitrary smaller matrix. Shouldn't this be possible with std::copy, where I'm certain the number of elements in the 1D array are equivalent to those in the dummy?
int dummy[210][210][1000];
std::copy(&block[0], &block[block.size()], &dummy);
View 2 Replies
View Related
Feb 27, 2012
I want to assign a matrix to submatrix of a bigger matrix.
ublas::matrix<int> A(8,5);
ublas::matrix<int> B(2,5);
for(size_t i=0;i<A.size1();++i)
for(size_t j=0;j<A.size2();++j)
A(i,j)=i*A.size2()+j+1;
for(size_t i=0;i<B.size1();++i)
for(size_t j=0;j<B.size2();++j)
B(i,j)=i*B.size2()+j+5;
ublas::matrix_range<ublas::matrix<int> > a(A,ublas::range(0,2),ublas::range(0,5));
a=B;
and it works.
but if the matrix is compressed_matrix type, there's something with it. the error log as below:
Check failed in file boost_1_48_0/boost/numeric/ublas/detail/matrix_assign.hpp at line 1078:
detail::expression_type_check (m, cm)
terminate called after throwing an instance of 'boost::numeric::ublas::external_logic'
what(): external logic
Aborted
I'm not sure this is a bug or not.
View 2 Replies
View Related
Nov 9, 2014
Essentially what I need to do is take a text file, ("input.txt"):
4 4
1 0 0 1
1 1 1 1
0 0 1 0
0 0 1 0
And take the first two values on line 1 (4, 4) and use them as length and width.
Number of rows: 4
Number of columns: 4
Then I need to print out the matrix and further manipulate it. I need to find the sum of the 1's per column and then take that number and replace each 1 with the 1's in each column.
So it'll look like this:
2 0 0 2
2 1 3 2
0 0 3 0
0 0 3 0
The part that's mostly troubling me is that my instructor will be giving me the input file with random values, so I don't know what the matrix dimensions will be.
I can read the 2D array but can't seem to use it after. I need to find a way to skip the first line, and then read in the matrix and be able to use it mathematically to add up each column.
View 1 Replies
View Related
Jan 8, 2015
Using two-dimensional arrays, write a program which multiplies an mxn matrix of integers by an nxr
matrix of integers.
INPUT FIRST (2x2) MATRIX:
Type in 2 values for row 1 separated by spaces: 3 4
Type in 2 values for row 2 separated by spaces: 5 7
INPUT SECOND (2x2) MATRIX:
Type in 2 values for row 1 separated by spaces: 1 1
Type in 2 values for row 2 separated by spaces: 2 2
3 4
5 7
TIMES
1 1
2 2
EQUALS
11 11
19 19
View 1 Replies
View Related
Jan 31, 2014
what if we want to print both the diagonal elements!!!!
View 1 Replies
View Related
Oct 8, 2014
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,b;
int Rowsize , Colsize ;
int A[Rowsize][Colsize];
[Code] ....
View 1 Replies
View Related
Jul 27, 2013
I have an array matrix called tmat,,and i know that in every row of tmax there are values which repeat two times...and am writing a code to extract the values WHICH DOES NOT REPEAT into another matrix called tcopy...the codes compiles fine...and it writes nicely to file...but without the desired result...
One last question...how can i get the array tcopy written to file in the form 5x3...and not all the figures in line one after the other? i mean i wish to see the matrix like a matrix on file..not like a list of numbers....
Code:
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int R = 5;
const int C = 5;
[Code] ....
View 14 Replies
View Related
Dec 1, 2014
I had the following question in my exam paper and only got 1.5 out of a possible 6 marks. This is the question:
Given the Matrix class:
class Matrix {
public:
Matrix(unsigned r, unsigned c);
Matrix(const Matrix<T>& rhs);
~Matrix();
const Matrix<T>&operator=(const Matrix<T>& rhs);
[Code] ....
Use the linkedStackType class (Array implementation of stack) and write a function reverseCols to reverse the order of columns in the matrix. Note that reverseCols is not a member function of the Matrix class therefore only the public interface of matrix can be used.
//Implementation of Stacks as Array
template<class Type>
class stackType: public stackADT<Type> {
public:
const stackType<Type>& operator=(const stackType<Type>&);
[Code] ....
What is the correct solution must be to reverse the columns of the matrix?
View 1 Replies
View Related
May 25, 2014
I have to prepare a project. But I don t know how can I do this. Program will find a matrix P for a square matrix A such that P^-1 A P ....
View 15 Replies
View Related
Oct 4, 2014
3 3
2 1 3 2 3
1 0 2
1 2 6
First line shows row and column number
First index of the second line tells the number of non-zero entries of the first row and second index tell the column number where the non zero entry is placed
for 1st row of matrix:
non-zero entries=2
column number=1
non-zero entry=3
column number=2
non-zero entry=2
covert this in the given form
0 3 3
2 0 0
0 0 6
View 1 Replies
View Related