SHARE
TWEET

Untitled

a guest Sep 20th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main ()
  5. {
  6.     float x[4][4];
  7.     int i,j,N,M;
  8.    
  9.     cout<<"Upisite dimenzije niza"<<endl;
  10.    
  11.     do
  12.     {
  13.         cout<<"broj redova=";
  14.         cin>>N;
  15.         cout<<"Broj kolona=";
  16.         cin>>M;
  17.     }
  18.    
  19.     while ((N>4)||(M>3));
  20.     for(i=0;i<N;i++)
  21.     {
  22.         cout<<"Unesite elemente niza"<<endl;
  23.         for(j=0;j<M;j++)
  24.         {
  25.         cout<<"x["<<i<<","<<j<<"]=";
  26.         cin>>x[i][j];
  27.     }
  28. }
  29.     cout<<"Niz je ucitan"<<endl;
  30.  
  31.     cout<<"Upisali ste niz"<<endl;
  32.     for(i=0;i<N;i++)
  33.     {
  34.     for (j=0;j<M;j++)
  35.     {
  36.         cout<<setw(6)<<x[i][j];
  37.     }
  38.    
  39.     cout<<endl;
  40.     }
  41.     cout<<"Elemenit na glavnoj dijagonali su : ";
  42.     for (i=0;i<N;i++)
  43.     {
  44.         cout<<setw(3)<<x[i][N-i-1];
  45.     }
  46. return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top