diff options
| author | JacobAKnox <[email protected]> | 2021-12-03 11:51:11 -0800 |
|---|---|---|
| committer | JacobAKnox <[email protected]> | 2021-12-03 11:51:11 -0800 |
| commit | d0a97a57807fce1dbd093a96837bfd93120b141c (patch) | |
| tree | 6574bc670bbb44a864aa57eb84e4784734393d6b | |
| parent | Add online IDE url (diff) | |
| download | cst116-proj3-jacobaknox-d0a97a57807fce1dbd093a96837bfd93120b141c.tar.xz cst116-proj3-jacobaknox-d0a97a57807fce1dbd093a96837bfd93120b141c.zip | |
| -rw-r--r-- | project3/notes.txt | 27 | ||||
| -rw-r--r-- | project3/output.txt | 133 | ||||
| -rw-r--r-- | project3/project3.cpp | 182 | ||||
| -rw-r--r-- | project3/project3.h | 22 | ||||
| -rw-r--r-- | project3/project3.sln | 31 | ||||
| -rw-r--r-- | project3/project3.vcxproj | 150 | ||||
| -rw-r--r-- | project3/project3.vcxproj.filters | 27 | ||||
| -rw-r--r-- | project3/pseuodocode.txt | 80 |
8 files changed, 652 insertions, 0 deletions
diff --git a/project3/notes.txt b/project3/notes.txt new file mode 100644 index 0000000..14a811f --- /dev/null +++ b/project3/notes.txt @@ -0,0 +1,27 @@ +Meeting notes: + No meeting notes beccause i did this myself after several attempts to contact my partner + +Agile: + + Break down the project and write the pseudocode + Ill need to store two matricies and be able to add and multiply them + I need to figure out how to add and multiply matrices + + Write most of the code and get it to compile + I need to convert the pseudocode to code + who do i detect an input error and format the output of a matrix + + Test and debug the code I wrote + The code compiles but likely have many errors i need to fix + Figure out what pair(s) of matricies are best for testing + +Testing: + add and multiply the following matrix pairs and make sure the correct answers are output without restarting the program + + 1 2 3 4 5 3 5 7 6 14 37 21 + 4 5 6 2 7 9 -> 6 12 15 38 91 57 + 7 8 9 2 6 0 9 14 9 62 145 93 + + 3 0 -1 1 -5 0 4 -5 -1 3 -14 -3 + 0 4 2 4 1 -2 -> 4 5 0 16 2 -2 + 5 -3 1 0 -1 3 5 -4 4 -7 -29 9
\ No newline at end of file diff --git a/project3/output.txt b/project3/output.txt new file mode 100644 index 0000000..5030f60 --- /dev/null +++ b/project3/output.txt @@ -0,0 +1,133 @@ +Input the values for the first matrix: +Input the matrix value at 1, 1: 1 +Input the matrix value at 1, 2: 2 +Input the matrix value at 1, 3: 3 +Input the matrix value at 2, 1: 4 +Input the matrix value at 2, 2: 5 +Input the matrix value at 2, 3: 6 +Input the matrix value at 3, 1: 7 +Input the matrix value at 3, 2: 8 +Input the matrix value at 3, 3: 9 +Input the values for the second matrix: +Input the matrix value at 1, 1: 4 +Input the matrix value at 1, 2: 5 +Input the matrix value at 1, 3: 3 +Input the matrix value at 2, 1: 2 +Input the matrix value at 2, 2: 7 +Input the matrix value at 2, 3: 9 +Input the matrix value at 3, 1: 2 +Input the matrix value at 3, 2: 6 +Input the matrix value at 3, 3: 0 + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 3 +The result of adding +[1.000][2.000][3.000] +[4.000][5.000][6.000] +[7.000][8.000][9.000] +with +[4.000][5.000][3.000] +[2.000][7.000][9.000] +[2.000][6.000][0.000] +is: +[5.000][7.000][6.000] +[6.000][12.000][15.000] +[9.000][14.000][9.000] + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 2 +The result of multiplying +[1.000][2.000][3.000] +[4.000][5.000][6.000] +[7.000][8.000][9.000] +with +[4.000][5.000][3.000] +[2.000][7.000][9.000] +[2.000][6.000][0.000] +is: +[14.000][37.000][21.000] +[38.000][91.000][57.000] +[62.000][145.000][93.000] + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 1 +Input the values for the first matrix: +Input the matrix value at 1, 1: 3 +Input the matrix value at 1, 2: 0 +Input the matrix value at 1, 3: -1 +Input the matrix value at 2, 1: 0 +Input the matrix value at 2, 2: 4 +Input the matrix value at 2, 3: 2 +Input the matrix value at 3, 1: 5 +Input the matrix value at 3, 2: -3 +Input the matrix value at 3, 3: 1 +Input the values for the second matrix: +Input the matrix value at 1, 1: 1 +Input the matrix value at 1, 2: -5 +Input the matrix value at 1, 3: 0 +Input the matrix value at 2, 1: 4 +Input the matrix value at 2, 2: 1 +Input the matrix value at 2, 3: -2 +Input the matrix value at 3, 1: 0 +Input the matrix value at 3, 2: -1 +Input the matrix value at 3, 3: 3 + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 3 +The result of adding +[3.000][0.000][-1.000] +[0.000][4.000][2.000] +[5.000][-3.000][1.000] +with +[1.000][-5.000][0.000] +[4.000][1.000][-2.000] +[0.000][-1.000][3.000] +is: +[4.000][-5.000][-1.000] +[4.000][5.000][0.000] +[5.000][-4.000][4.000] + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 2 +The result of multiplying +[3.000][0.000][-1.000] +[0.000][4.000][2.000] +[5.000][-3.000][1.000] +with +[1.000][-5.000][0.000] +[4.000][1.000][-2.000] +[0.000][-1.000][3.000] +is: +[3.000][-14.000][-3.000] +[16.000][2.000][-2.000] +[-7.000][-29.000][9.000] + --Matirx Prorgam-- +1. Input new matricies +2. Multiply matricies +3. Add matricies +4. Exit Program + +Input your choice: 4 +Exiting program... +C:\Users\jakno\source\repos\CST116\project3\Debug\project3.exe (process 13744) exited with code 0. +Press any key to close this window . . . diff --git a/project3/project3.cpp b/project3/project3.cpp new file mode 100644 index 0000000..6c5ca59 --- /dev/null +++ b/project3/project3.cpp @@ -0,0 +1,182 @@ +// project3.cpp : This file contains the 'main' function. Program execution begins and ends there. +// +//Written by Jacob Knox: [email protected] + +#include <iostream> +#include <string> +#include <iomanip> +#include "project3.h" + +using namespace std; + +int main() +{ + float m1[MATRIX_SIZE][MATRIX_SIZE], m2[MATRIX_SIZE][MATRIX_SIZE]; + int choice = 0; + + //make sure you have matricies before giving options + getMatricies(m1, m2); + menu(choice, m1, m2); +} + +void menu(int choice, float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]) +{ + string menu = "\t\t--Matirx Prorgam--\n\ +1. Input new matricies\n\ +2. Multiply matricies\n\ +3. Add matricies\n\ +4. Exit Program\n\n\ +Input your choice: "; + + //choice == 4 means quit and retturn to main + //main program loop + while (choice != 4) + { + choice = readInt(menu, "Error please input an integer 1-4.\n"); + + switch (choice) + { + case 1: + getMatricies(m1, m2); + break; + case 2: + multiplyMatrix(m1, m2); + break; + case 3: + addMatrix(m1, m2); + break; + case 4: + cout << "Exiting program..."; + break; + default: + cout << "Error unknown choice " << choice << ". Please try again."; + break; + } + } +} + +//reads two matricies from user +void getMatricies(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]) +{ + cout << "Input the values for the first matrix:\n"; + getMatrix(m1); + + cout << "Input the values for the second matrix:\n"; + getMatrix(m2); +} + +// reads all the values for a single matrix +void getMatrix(float mat[MATRIX_SIZE][MATRIX_SIZE]) +{ + for (int x = 0; x < MATRIX_SIZE; x++) + { + for (int y = 0; y < MATRIX_SIZE; y++) + { + mat[x][y] = readFloat("Input the matrix value at " + to_string(x+1) + ", " + to_string(y+1) + ": ", "Error invalid value. Please input a float.\n"); + } + } +} + +// adds matrix 1 and 2 and shows result +void addMatrix(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]) +{ + float result[MATRIX_SIZE][MATRIX_SIZE]; + + for (int x = 0; x < MATRIX_SIZE; x++) + { + for (int y = 0; y < MATRIX_SIZE; y++) + { + //adding matrix is adding each spot to corresponding spot in result + result[x][y] = m1[x][y] + m2[x][y]; + } + } + + cout << "The result of adding\n"; + printMatrix(m1); + cout << "with\n"; + printMatrix(m2); + cout << "is:\n"; + printMatrix(result); +} + +//multiplies thw two matrices +void multiplyMatrix(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]) +{ + float result[MATRIX_SIZE][MATRIX_SIZE]; + + for (int x = 0; x < MATRIX_SIZE; x++) + { + for (int y = 0; y < MATRIX_SIZE; y++) + { + //result for a specific spot is the dot product of that spot in the two matrices + result[x][y] = calulateDotProduct(x, y, m1, m2); + } + } + + cout << "The result of multiplying\n"; + printMatrix(m1); + cout << "with\n"; + printMatrix(m2); + cout << "is:\n"; + printMatrix(result); +} + +//dot product is multiplying the corresponding values in one matrix collunm/ row and adding the results of that +float calulateDotProduct(int x, int y, float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]) +{ + float product = 0; + + for (int i = 0; i < MATRIX_SIZE; i++) + { + product += m1[x][i]*m2[i][y]; + } + return product; +} + +//reads an int from the user, will output error if it fails and repeat asking until it gets a good answer +int readInt(const std::string& question, const std::string& error) +{ + int value; + + cout << question; + while (!(cin >> value)) + { + cin.clear(); + while (cin.get() != '\n') continue; + cout << error; + cout << question; + } + + return value; +} + +//reads an float from the user, will output error if it fails and repeat asking until it gets a good answer +float readFloat(const std::string& question, const std::string& error) +{ + float value; + + cout << question; + while (!(cin >> value)) + { + cin.clear(); + while (cin.get() != '\n') continue; + cout << error; + cout << question; + } + + return value; +} + +//prints a matrix by looping over it and formatting appropiately +void printMatrix(float mat[MATRIX_SIZE][MATRIX_SIZE]) +{ + for (int x = 0; x < MATRIX_SIZE; x++) + { + for (int y = 0; y < MATRIX_SIZE; y++) + { + cout << setprecision(3) << fixed << "[" << mat[x][y] << "]"; + } + + cout << endl; + } +}
\ No newline at end of file diff --git a/project3/project3.h b/project3/project3.h new file mode 100644 index 0000000..4215a38 --- /dev/null +++ b/project3/project3.h @@ -0,0 +1,22 @@ +#pragma once +#include <string> + +const int MATRIX_SIZE = 3; + +void menu(int choice, float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]); + +void getMatricies(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]); + +void getMatrix(float mat[MATRIX_SIZE][MATRIX_SIZE]); + +void addMatrix(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]); + +void multiplyMatrix(float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]); + +float calulateDotProduct(int x, int y, float m1[MATRIX_SIZE][MATRIX_SIZE], float m2[MATRIX_SIZE][MATRIX_SIZE]); + +int readInt(const std::string& question, const std::string& error); + +float readFloat(const std::string& question, const std::string& error); + +void printMatrix(float mat[MATRIX_SIZE][MATRIX_SIZE]); diff --git a/project3/project3.sln b/project3/project3.sln new file mode 100644 index 0000000..5b827cb --- /dev/null +++ b/project3/project3.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31829.152 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "project3", "project3.vcxproj", "{A17F750C-4B6F-4184-BE86-C7A197258A2A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Debug|x64.ActiveCfg = Debug|x64 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Debug|x64.Build.0 = Debug|x64 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Debug|x86.ActiveCfg = Debug|Win32 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Debug|x86.Build.0 = Debug|Win32 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Release|x64.ActiveCfg = Release|x64 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Release|x64.Build.0 = Release|x64 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Release|x86.ActiveCfg = Release|Win32 + {A17F750C-4B6F-4184-BE86-C7A197258A2A}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CE0775C3-3E79-4704-A754-22E6F627BDA0} + EndGlobalSection +EndGlobal diff --git a/project3/project3.vcxproj b/project3/project3.vcxproj new file mode 100644 index 0000000..a53514a --- /dev/null +++ b/project3/project3.vcxproj @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>16.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{a17f750c-4b6f-4184-be86-c7a197258a2a}</ProjectGuid> + <RootNamespace>project3</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="project3.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="project3.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/project3/project3.vcxproj.filters b/project3/project3.vcxproj.filters new file mode 100644 index 0000000..8ea92a7 --- /dev/null +++ b/project3/project3.vcxproj.filters @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="project3.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="project3.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/project3/pseuodocode.txt b/project3/pseuodocode.txt new file mode 100644 index 0000000..e01085b --- /dev/null +++ b/project3/pseuodocode.txt @@ -0,0 +1,80 @@ +main: + m1 = [][] + m2 = [][] + int choice = 0; + getMatricies(m1, m2); + menu(choice, m1, m2); + +menu(choice, m1, m2) + while choice != 4 + choice = readInt(menu, error message) + + switch + 1: + getMatrices(m1, m2) + 2: + multiply(m1, m2) + 3: + add(m1, m2) + 4: + outout exit message + defualt: + error try again + +getMatricies(&m1, &m2) + getMatrix(m1) + getMatrix(m2) + + +getMatrix(&m) + for (x 0-2) + for (y 0-2) + m[x][y] = readfloat(input value for x, y; error message) + +readInt(question, error) + int value + ouptut question + read input to value + while cin error + ouptut error + output question + read input -> value + return value + +readFloat(question, error) + float value + ouptut question + read input to value + while cin error + ouptut error + output question + read input -> value + return value + +printMatrix(m) + for (x 0-2) + for (y 0-2) + output m[x][y] + newline + +add(m1, m2) + result = [][] + for x 0-2 + for y 0-2 + result[x][y] = m1[x][y] + m2[x][y] + + printMatrix(result) + +multiply(m1, m2) + result = [][] + for x 0-2 + for y 0-2 + result[x][y] = dotproduct(x, y, m1, m2) + + printMatrix(result) + +dotproduct(x, y, m1, m2) + product = 0 + for i 0-2 + product += m1[x][i] * m2[i][y] + return product |