Each individual list will represent a row. For instance [[1,1,1],[2,2,2],[3,3,3]
ID: 3598750 • Letter: E
Question
Each individual list will represent a row. For instance [[1,1,1],[2,2,2],[3,3,3]] represents a matrix with all entries in the i th row being equal to i.
Using Python, Write a function matMul, which accepts two arguments. When being called as matMul(A,B) with matrices A, B the function must
-return the matrix product A*B, if isMatrix(A) and isMatrix(B) are both True and the number of columns in A is equal to the number of rows in B;
-otherwise the function must return a string "invalid arguments"
*Please go step by step and can you please explain why for each step*
Explanation / Answer
#include
#include
#include
#include "Container.h"
#include "Pet.h"
#include "Checkup.h"
using namespace std;
// forward declarations
void flush();
void branching(char);
void helper(char);
void add_pet(string, string);
Pet* search_pet(string, string);
void remove_pet(string, string);
void clean_up(Pet*);
void print_all(Container*);
void remove_all();
Container* list = NULL; // global list
int main()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // Use to check for memory leaks in VS
char ch = 'i';
do {
// Q6: Implement cin / cout for the lines below without modifying the functionality (5 points)
// (change all printf statements to cout and read the next char using cin)
printf("Please enter your selection ");
printf(" a: add a new pet to the list ");
printf(" c: add a new checkup for a pet ");
printf(" r: remove a pet from the list ");
printf(" p: print all pets on the list ");
printf(" q: quit ");
ch = getchar();
// End Q6
flush();
branching(ch);
} while (ch != 'q');
remove_all();
list = NULL;
return 0;
}
void flush()
{
int c;
do c = getchar(); while (c != ' ' && c != EOF);
}
void branching(char c)
{
switch (c) {
case 'a':
case 'c':
case 'r':
case 'p':
helper(c);
break;
case 'q':
break;
default:
printf(" Invalid input! ");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.