Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int kvad(int **mat ,int red,int stupac);
  7.  
  8. int main()
  9.     {
  10.  
  11.     int red, stupac;
  12.  
  13.     do{
  14.     cout<<"Unesite broj redaka: ";
  15.     cin>>red;
  16.     cout<<"Unesite broj stupaca: ";
  17.     cin>>stupac;
  18.     }while(red >10 || stupac >10);
  19.  
  20.     int **mat= new int*[red];
  21.     for(int i=0;i<red;i++)
  22.         {
  23.             mat[i]=new int[stupac];
  24.         }
  25.  
  26.     cout<<"Unesi elemente matrice: "<<endl;
  27.     for(int i=0;i<red;i++)
  28.     {
  29.         for(int j=0;j<stupac;j++)
  30.         {
  31.  
  32.             cin>>*(*(mat+i)+j);
  33.         }
  34.     }
  35.     cout<<endl<<"Matrica: "<<endl<<endl;
  36.     for(int i=0;i<red;i++)
  37.     {
  38.         for (int j=0;j<stupac;j++)
  39.             {
  40.             cout<<*(*(mat+i)+j)<<"\t";
  41.             }cout<<endl;
  42.     }
  43.  
  44.     cout<<endl;
  45.     cout<<endl;
  46.  
  47.     kvad(mat,red,stupac);
  48.     cout<<"Kvadrirana matrica: "<<endl<<endl;
  49.     for(int i=0;i<red;i++)
  50.     {
  51.         for (int j=0;j<stupac;j++)
  52.             {
  53.             cout<<*(*(mat+i)+j)<<"\t";
  54.             }cout<<endl;
  55.     }
  56.  
  57.     for(int i=0; i<red; i++)
  58.     {
  59.         delete []mat[i];
  60.         delete []mat;
  61.     }
  62.  
  63. return 0;
  64. }
  65.  
  66. int kvad(int **mat,int red, int stupac)
  67.     {
  68.         for(int i=0;i<red;i++)
  69.         {
  70.             for (int j=0;j<stupac;j++)
  71.             {
  72.             *(*(mat+i)+j)= pow(*(*(mat+i)+j),2);
  73.             }
  74.         }
  75.     return **mat;
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement