How Can Miss_Lolitta Program an Integer Matrix with Symmetrical Constraints?

  • Thread starter Thread starter Miss_lolitta
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around a programming homework problem where the goal is to create an integer matrix with specific symmetrical constraints. Participants explore the requirements of the matrix, including its dimensions, entry values, and the conditions that must be met for rows and columns.

Discussion Character

  • Homework-related
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Miss_Lolitta outlines the requirements for the matrix, including dimensions, entry values, and specific constraints on the arrangement and totals of rows and columns.
  • One participant inquires about the programming language to be used for the implementation.
  • Another participant suggests that Miss_Lolitta should attempt the problem herself before seeking help, implying that engagement with the material is important.
  • A participant questions whether the thread is in the correct section, suggesting it may belong in a homework category.
  • Miss_Lolitta expresses a preference for writing the program in C++ and indicates her desire to improve her programming skills with assistance.
  • One participant emphasizes the importance of designing the logic of the program before coding, suggesting a step-by-step approach to problem-solving.
  • Another participant provides a mathematical method to visualize the problem, proposing a systematic way to fill the matrix while adhering to the constraints, and presents a potential solution with specific values.
  • There is a hint about the symmetry in the matrix and the relationship between mathematics and computer science in solving such problems.

Areas of Agreement / Disagreement

Participants express varying levels of engagement with the problem, with some focusing on programming aspects while others emphasize mathematical reasoning. There is no consensus on a single approach to solving the problem, and multiple viewpoints on how to proceed are present.

Contextual Notes

The discussion includes various assumptions about the programming logic and mathematical relationships that may not be fully explored or resolved. The participants' suggestions and methods may depend on their interpretations of the problem's requirements.

Miss_lolitta
Messages
10
Reaction score
0
Hi,,
I am hoping that you will help me. I have trouble how can do this homework:
Write a program that allows the user to input a number of integers such as N, and then stores them in an integer matrix where:

1- The dimension of matrix = NXN.
2-Entries of matrix can take any number from 0-2.
3- Arrangement of entries of first row is the same arrangement of entries of first column.
4-The diagonal of matrix =o.
5- Total of every row =4,Also Total of every column.

Then, the program displays the result.

Your help would greatly be appreciated

Respectfully,,
Miss_Lolitta
 

Attachments

Computer science news on Phys.org
Is there a particular language that the program is to be written in?
 
hey perhaps we can sit your exams for you too?

At least try and do it, and post what progress you have gotten through!
 
Isn't this in the wrong section? Shouldn't it be in the homework section?
 
I would like to write this program in C++.I learn the programming language at an institute,and I am not expert in this branch but I try to become better with your first help.

I would be so ever grateful if you could help me on how to go about writing this program.

thanks,,
 
OK, forget about the programming language, forget about the computer. Pick up a pencil.

Design you logic first. Start at a high level, then break it down.
1] Gets integer from user: N.
2] Creates a matrix: NxN.
3] Fills in the diagonal values with zeros.
4] ?? - You must decide on your algorthim for checking against your rules.

Clearly step 4 is the bulk of the program. How do you propose to check?
Brute force?
000 000 000 = No.
000 000 001 = No
000 000 002 = No
000 000 010 = No
etc.
Is there a better way to do this? Knowing the rules you have to stay within, and the possible values (0-2), are there any steps you can eliminate? (Note that of the above tests, only 2 of them are valid, considering the "diagonal rule". You don't even need to test them.)

Hint: you're going to be needing a lot of loops and a lot of 'if's.

There is no point in going anywhere near a programming language or a computer until you've worked out your logic.
 
Last edited:
Really, forget about the programming language, forget about the computer. Look at this method to solve this problem in maths:

1] Gets integer from user: N. such as N=3

2] Creates a matrix: 3x3

X Y Z
X Y Z
X Y Z

3] Fills in the diagonal values with zeros.

0 Y Z
X 0 Z
X Y 0

>>> then we have the following system:

0 Y Z = 4
X 0 Z = 4
X Y 0 = 4

>>> by solving this system we have a unique solution:X=2,Y=2,Z=2

>>> So, we have matrix

0 2 2
2 0 2
2 2 0


Hint: we have a symmetry between diagonals of matrix

I know that there is relation between maths and CS to solve mathematical problems..because of this I would like to study the programming languages.

Any help you give I'd be very glad . Thank you for your assistance.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K