Hi could someone please helping in starting this program? I am not asking anyone to do my work for me i just want to know how i can start the program and steps to follow please( i am new to c++) thanks
write a program that reads an n*n matrix file in the form(for the 2*2 case)
2
1 2
3 4
and then overwrites this file by replacing each element by the average of its four adjacent elements(right,left,up and down). The first line of the file indicates the number of row and column elements of the matrix. If an adjacent element is outside the matrix boundary, its value is taken to zero. You can close and open the file more than once.
hawita
-3
Light Poster
Recommended Answers
Jump to Post#include<iostream> using namespace std; int main() { int *matrix; int dimension; /*read dimension first and initialise "dimension" and then allocate apropriate memory to "matrix" and then read the matrix into this array. This can also be done inside a function which will make your code more usable*/ …
Jump to PostThis is fine as well. But you do not know the dimension of the matrix before reading the file. So how do you declare the int array to store the matrix.
if the dimension you read from the input file is say N, you can allocate memory to the …
All 5 Replies
hawita
-3
Light Poster
dkalita
110
Posting Pro in Training
hawita
-3
Light Poster
hawita
-3
Light Poster
dkalita
110
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.