Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void validar(int *);
- void cargarMatriz(int);
- unsigned long potencia(int, int);
- int main(){
- int m;
- cout<<"Ingrese orden de la matriz: ";
- cin>>m;
- validar(&m);
- cargarMatriz(m);
- }
- void validar(int *M){
- while(*M > 10){
- cout<<"Orden no valido, ingrese un numero menor o igual a 10: ";
- cin>>*M;
- }
- }
- void cargarMatriz(int m){
- int numero = 1,f,c, mat[m][m];
- for(f = 0; f<m; f++){
- for(c = 0; c<m; c++){
- mat[f][c] = potencia(numero, numero); //EN UN PUNTO IMPRIME BASURA PORQUE EL NUMERO YA ES MUY GRANDE
- numero++;
- }
- }
- for(f = 0; f<m; f++){
- for(c = 0; c<m; c++){
- cout<<mat[f][c]<<"\t";
- }
- cout<<"\n";
- }
- }
- unsigned long potencia(int base, int exponente){
- if(exponente == 0){
- return 1;
- }else{
- return base * potencia(base, exponente-1); //LLAMADA RECURSIVA
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement