https://github.com/kplanisphere/matrix-vector-ops-cpp
Proyecto 1 - Estructuras de Datos
https://github.com/kplanisphere/matrix-vector-ops-cpp
2d-matrices algorithm-implementation beginner-projects cpp data-structures dynamic-arrays matrix-operations vector-operations
Last synced: 4 months ago
JSON representation
Proyecto 1 - Estructuras de Datos
- Host: GitHub
- URL: https://github.com/kplanisphere/matrix-vector-ops-cpp
- Owner: KPlanisphere
- Created: 2024-05-30T19:37:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-30T19:40:08.000Z (about 1 year ago)
- Last Synced: 2024-12-29T15:26:02.969Z (6 months ago)
- Topics: 2d-matrices, algorithm-implementation, beginner-projects, cpp, data-structures, dynamic-arrays, matrix-operations, vector-operations
- Language: C++
- Homepage: https://linktr.ee/planisphere.kgz
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Matrix Vector Operations in C++
### Description
This project demonstrates basic operations on a 2D matrix using vectors in C++. The main functionalities include creating a matrix based on user input, displaying the matrix, and modifying the matrix values. The project is suitable for beginners learning about dynamic data structures and input/output operations in C++.
### Features
- Dynamic matrix creation based on user input for rows and columns.
- Input values for each element of the matrix.
- Display the initial matrix.
- Modify the matrix elements based on new user input.
- Display the modified matrix.### Code Snippets
**Matrix Creation and Initial Display:**
```cpp
#include
#includeint main() {
int fil, col;
int val = 0;
std::vector< std::vector > matriz;std::cout << "FILAS: ";
std::cin >> fil;
std::cout << "COLUMNAS: ";
std::cin >> col;for (int i = 0; i < fil; i++) {
std::vector v1;
for (int j = 0; j < col; j++) {
std::cout << "Valor [" << i << "][" << j << "] = ";
std::cin >> val;
v1.push_back(val);
}
matriz.push_back(v1);
}for (int i = 0; i < matriz.size(); i++) {
for (int j = 0; j < matriz[i].size(); j++) {
std::cout << matriz[i][j] << " ";
}
std::cout << std::endl;
}system("pause");
}
```
**Matrix Modification and Display:**
```cpp
std::cout << "\nALTERANDO LOS ELEMENTOS!!!" << std::endl;
int nuevos;
for (int i = 0; i < fil; i++) {
for (int j = 0; j < col; j++) {
std::cout << "Valor [" << i << "][" << j << "] = ";
std::cin >> nuevos;
matriz[i][j] = nuevos;
}
}for (int i = 0; i < matriz.size(); i++) {
for (int j = 0; j < matriz[i].size(); j++) {
std::cout << matriz[i][j] << " ";
}
std::cout << std::endl;
}system("pause");
}
```### How to Run
1. Compile the code using a C++ compiler, e.g., `g++ -o matrix matrix_vector_ops.cpp`.
2. Run the executable, e.g., `./matrix`.
3. Follow the on-screen prompts to input the matrix dimensions and values.
4. View the initial matrix.
5. Modify the matrix values as prompted and view the updated matrix.### Requirements
- C++ compiler
- Standard Library