Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include<iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. float x [4][4];
  7.  
  8. int i,j,M,N;
  9. cout<<"Upisite dimenzije niza"<<endl;
  10. do {
  11. cout<<"Unesite broj redova: ";
  12. cin>>N;
  13. cout<<"Unesite broj kolona: ";
  14. cin>>M;
  15. } while ((N>4)||(M>3));
  16.  
  17. for (i=0;i<N;i++){
  18. cout<<"Unesite elemente niza";
  19. for (j=0;j<M;j++){
  20. cout<<"x["<<i<<","<<j<<"]=";
  21. cin>>x[i][j];
  22. }
  23.  
  24. }
  25. cout<<"Niz je ucitan"<<endl;
  26. cout<<"Upisali ste niz"<<endl;
  27. for (i=0;i<N;i++)
  28. for(j=0;j<M;j++){
  29. for(j=0; j<M; j++)
  30. {
  31. cout<<setw(6)<<x[i][j];
  32. }
  33. cout<<endl;
  34. }
  35. cout<<"Elementi na glavnoj dijagonali su: "<<endl;
  36. for(i=0; i<N; i++)
  37. {
  38. cout<<setw(3)<<x[i][N-i-1];
  39. }
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement