Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int kvad(int **mat ,int red,int stupac);
- int main()
- {
- int red, stupac;
- do{
- cout<<"Unesite broj redaka: ";
- cin>>red;
- cout<<"Unesite broj stupaca: ";
- cin>>stupac;
- }while(red >10 || stupac >10);
- int **mat= new int*[red];
- for(int i=0;i<red;i++)
- {
- mat[i]=new int[stupac];
- }
- cout<<"Unesi elemente matrice: "<<endl;
- for(int i=0;i<red;i++)
- {
- for(int j=0;j<stupac;j++)
- {
- cin>>*(*(mat+i)+j);
- }
- }
- cout<<endl<<"Matrica: "<<endl<<endl;
- for(int i=0;i<red;i++)
- {
- for (int j=0;j<stupac;j++)
- {
- cout<<*(*(mat+i)+j)<<"\t";
- }cout<<endl;
- }
- cout<<endl;
- cout<<endl;
- kvad(mat,red,stupac);
- cout<<"Kvadrirana matrica: "<<endl<<endl;
- for(int i=0;i<red;i++)
- {
- for (int j=0;j<stupac;j++)
- {
- cout<<*(*(mat+i)+j)<<"\t";
- }cout<<endl;
- }
- for(int i=0; i<red; i++)
- {
- delete []mat[i];
- delete []mat;
- }
- return 0;
- }
- int kvad(int **mat,int red, int stupac)
- {
- for(int i=0;i<red;i++)
- {
- for (int j=0;j<stupac;j++)
- {
- *(*(mat+i)+j)= pow(*(*(mat+i)+j),2);
- }
- }
- return **mat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement