Task:
It is necessary to create matrices А and В type char dimension mxn and fill them with values like
str1 = "1.1 -3.3 44.6" str2 = "3.4 -44.8 5.0" Values to enter from the keyboard, separating numbers with spaces. Fill one row of the matrix at a time. Then the string matrices need to be converted to double . Use the Split function to get individual lines, or the cin option. Calculate the expression С = ((А+В)^T)*(BA)
Questions:
What is the
Splitfunction and how can I use it to solve this problem? I can not find a clear explanation. Both in video tutorials and on websites, strings are converted todoubleusing cycles likefor (int i =0; i< str1.length; i++){ if (str1[i] != ' ') { string intermidiate += str1[i]; } else { double dnum = atof (intermidiate.c_str()); intermidiate.clear() vector <double> vec1.push_back (dnum); } // Для последнего числа строки double dnum = atof (intermidiate.c_str); intermidiate.clear() vector <double> vec1.push_back (dnum); }- What would this for loop look like for a two-dimensional array?
What is meant by "either
cincapabilities"?Тis a two-dimensional array used to transpose a matrix(A+B). How to implement it?#include <iostream> #include <cmath> #include <vector> #include <locale> #include <stdlib.h> #include <string> #include <windows.h> using namespace std; int main (void) { char *locale = setlocale (LC_ALL, ""); string str_a; cout << "Заполните первую строку матрицы А произвольными вещественными числами." << "В строке должно быть четыре числа. Разделите числа пробелами: \r\n"; getline(cin, str_a); string intermediate; double dnumA; vector <double> vecA1; for (int i = 0; i < str_a.length(); i++) { if (str_a [i] != ' ') { intermediate += str_a [i]; } else { dnumA = atof (intermediate.c_str()); intermediate.clear(); vecA1.push_back(dnumA); } } dnumA = atof (intermediate.c_str()); intermediate.clear(); vecA1.push_back(dnumA);