在C ++上寻求帮助 [英] look for help on c++

查看:78
本文介绍了在C ++上寻求帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿jadbenautho

我真的很需要你的帮助.
我是大一或计算机科学专业的第一年,我们正在使用c ++,这对我来说并不陌生.我希望你能帮助我.这是提示:

创建一个简单的矩阵计算器.计算器将能够:
读取矩阵(从文件中)对这些矩阵执行操作(在文件中指定)以显示结果并将结果写入文件中.我们将执行的操作包括:
矩阵加法矩阵乘法,计算矩阵的行列式,计算矩阵的转置.有关矩阵运算的更多信息,请在您喜欢的搜索引擎中搜索矩阵运算".我们发现一个站点确实提供了很多很好的信息,http://www.miislita.com/information-retrieval-tutorial/matrix-tutorial-2-matrix-operations.html

输入文件
文件的组织方式如下
#br在文件中指定的矩阵
first_matrix_#rows first_matrix_#columns
first_matrix
second_matrix_#rows second_matrix_#columns
second_matrix
.
.
.
Operations_until_eof
因此以下将是文件的示例
4
2 3
1 2 3
4 5 6
3 4
4 5 7 23
34 65 12 86
-1 38 -54 21
2 2
-1 5
-83 195
2 3
65 -4 123
54 12 -76
1 + 4
4 * 2
2T
3D
3I

假设和提示
假设矩阵将小于25行和25列,并且在单个输入文件中将少于25行.对于操作,矩阵和操作之间将没有空格.对于操作,编号的矩阵将以1开始使用尽可能多的使用函数
将问题分解为较小的部分,以便于调试.

hey jadbenautho

i really need your help man.
i am in my first year or computer science and we are using c++ and it is unfamiliar territory for me. I was hoping you could help me out. this is the prompt:

create a simple matrix calculator. The calculator will be able to:
read in matrices (from a file) perform operations on those matrices (as specified in the file) display the results and write the results to a file The operations we will be performing include:
matrix addition matrix multiplication calculating the determinant of a matrix calculating the transpose of a matrix For more information about matrix operations search for "matrix operations" in your favorite search engine. One site we found did have lots of good information http://www.miislita.com/information-retrieval-tutorial/matrix-tutorial-2-matrix-operations.html

Input File
A file will be organized as follows
#matrices specified in the file
first_matrix_#rows first_matrix_#columns
first_matrix
second_matrix_#rows second_matrix_#columns
second_matrix
.
.
.
operations_until_eof
so the following would be an example of the file
4
2 3
1 2 3
4 5 6
3 4
4 5 7 23
34 65 12 86
-1 38 -54 21
2 2
-1 5
-83 195
2 3
65 -4 123
54 12 -76
1+4
4*2
2T
3D
3I

Assumptions and Tips
Let''s say that matrices will be smaller than 25 rows and 25 columns and that you will have less than 25 of them in a single input file For the operations, there will be no spaces between matrices and operations For the operations, the numbering of matrices will start with 1 Use functions as much as you can to
break down problems into smaller pieces allow for easier debugging

推荐答案

您需要做的是将此处遇到的整个问题分解为更小,更易于管理的问题. >
您的特定分配有两个主要部分,它们是对任意大小的矩阵进行矩阵计算并解析输入文件.然后是将结果写入另一个文件的第三个简单得多的任务.

因此,解析输入文件可以再次分解为一些更简单的问题,您应该可以通过一些轻松的搜索就可以弄清楚.

What you need to do is break the whole problem you have here in to smaller more manageable problems.

There are two main portions to your particular assignment which are the matrix calculations on arbitrarily sized matrices and parsing the input file. There is then the third much simpler task of writing your results to another file.

So, parsing the input file can be broken down into a few much simpler problems again that you should be able to figure out by some light searching.

1. Open a file
2. Read lines from the file
3. parse each line to get the data you need
  3a. Line 1, Change string into int to get number of matrices in file
  3b. Line 2, split the string into two so you have a separate string for each number, then convert each string into an int to find out the size of the matrix
  3c. Parse Y lines and split into X number of ints to get the matrix data
Etc. 



我想你明白了.从文件读取和写入非常容易,因此您不应该很麻烦地查找有关该信息,并且应该可以找到许多有关使用n * n矩阵的文章,可能值得尝试搜索C ++文章.主题,这样您就不会陷入数学家喜欢使用的所有奇特符号的困扰(无论如何它们都会让我感到困惑).

由于这是一项任务,我们不能简单地为您提供解决方案,但是如果您有任何无法解决的特定问题或错误,则可以随时提出有关此问题的另一个问题.



I think you get the idea there. Reading and writing from files is fairly easy to do so you shouldn''t have much trouble finding information on that and you should be able to find numerous articles on working with n*n matrices, it might be worth trying to search for C++ articles on the subject so you don''t get to bogged down with all the fancy symbols that mathematicians like to use (They get me confused anyway).

As this is an assignment we can''t simply give you the solution but if you have any specific problems or bugs that you can''t work out you can always post another question about it.


这篇关于在C ++上寻求帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆