Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //~ using namespace std;
- using std::cout;
- using std::cin;
- using std::getline;
- using std::endl;
- using std::string;
- class Matriz
- {
- public:
- Matriz(int a): elementos(a)
- {
- int i;
- Elements=new int*[a];
- for(i=0;i<=a;i++)
- Elements[i]=new int[a];
- };
- int codifica();
- Matriz operator*(Matriz A);
- void insert(int row, int col, int value);
- int elementos;
- void MUL(Matriz A, Matriz B);
- //~ private:
- int **Elements;
- };
- int Matriz::codifica()
- {
- int hash=0;
- for(int i=0;i<elementos;i++)
- for(int j=0;j<elementos;j++)
- hash+=Elements[j][i];
- return hash;
- }
- void Matriz::insert(int row, int col, int value)
- {
- Elements[row][col]=value;
- }
- Matriz Matriz::operator*(Matriz A)
- {
- Matriz temp(A.elementos);
- temp.MUL((*this), A);
- return temp;
- }
- void Matriz::MUL(Matriz A, Matriz B)
- {
- int i, j, k;
- for(i=0;i<A.elementos;i++)
- for(j=0;j<A.elementos;j++)
- this->Elements[i][j]=0;
- for(i=0;i<=A.elementos;i++)
- {
- for(j=0;j<A.elementos;j++)
- {
- for(k=0;k<A.elementos;k++)
- {
- this->Elements[i][j]+=A.Elements[i][k]*B.Elements[k][j];
- }
- }
- }
- }
- int main()
- {
- Matriz A(3), B(3), C(3);
- string usuario, pass;
- cout<<"User: ";
- getline(cin, usuario);
- cout<<"Pass: ";
- getline(cin, pass);
- if(usuario.length()!=9 or pass.length()!=9)
- {
- cout<<"Denegado"<<endl;
- return 0;
- }
- for(int i=0;i<3;i++)
- for(int j=0;j<3;j++)
- A.insert(i, j, usuario[3*i+j]);
- for(int i=0;i<3;i++)
- for(int j=0;j<3;j++)
- B.insert(i, j, pass[3*i+j]);
- C= A*B;
- if(C.codifica() == 314875)
- cout<<"Aceptado"<<endl;
- else
- cout<<"Denegado"<<endl;
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement