Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- float x [4][4];
- int i,j,M,N;
- cout<<"Upisite dimenzije niza"<<endl;
- do {
- cout<<"Unesite broj redova: ";
- cin>>N;
- cout<<"Unesite broj kolona: ";
- cin>>M;
- } while ((N>4)||(M>3));
- for (i=0;i<N;i++){
- cout<<"Unesite elemente niza";
- for (j=0;j<M;j++){
- cout<<"x["<<i<<","<<j<<"]=";
- cin>>x[i][j];
- }
- }
- cout<<"Niz je ucitan"<<endl;
- cout<<"Upisali ste niz"<<endl;
- for (i=0;i<N;i++)
- for(j=0;j<M;j++){
- for(j=0; j<M; j++)
- {
- cout<<setw(6)<<x[i][j];
- }
- cout<<endl;
- }
- cout<<"Elementi na glavnoj dijagonali su: "<<endl;
- for(i=0; i<N; i++)
- {
- cout<<setw(3)<<x[i][N-i-1];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement