Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- #define ROW 3
- #define COL 4
- void pop(int **mat, vector<int> list){
- int count = 0;
- for(int x = 0;x < ROW;x++){
- for(int y = 0;y < COL;y++){
- mat[x][y] = list[count];
- count++;
- }
- }
- }
- void find_mat(int num, int **mat, int &r, int &c){
- for(int x = 0;x < ROW;x++){
- for(int y = 0;y < COL;y++){
- if(mat[x][y] == num){
- r = x;
- c = y;
- return;
- }
- }
- }
- }
- void prnt_mat(int **mat){
- for(int x = 0;x < ROW;x++){
- cout << "\t";
- for(int y = 0;y < COL;y++){
- cout << mat[x][y] << "\t";
- }
- cout << endl;
- }
- }
- int** crt_mat(){
- int **mat = new int*[ROW];
- for(int x = 0;x < 3;x++){
- mat[x] = new int[COL];
- }
- return mat;
- }
- int main() {
- int r = -1;
- int c = -1;
- int num;
- vector<int> list;
- int **mat = crt_mat();
- cin >> num;
- for(int x = 0;x < ROW*COL;x++){
- int tmp;
- cin >> tmp;
- list.push_back(tmp);
- }
- pop(mat, list);
- find_mat(num, mat, r, c);
- cout << "Matriz leida" << endl;
- prnt_mat(mat);
- cout << "Posicion del dato " << num << endl;
- cout << "Fila: " << r << endl;
- cout << "Columna: " << c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement