Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cout<<"Vnesi broj na redovi i koloni: ";
  9. cin>>n;
  10. int niza[n][n];
  11. for(int i=0;i<n;i++){
  12. for(int j=0;j<n;j++){
  13. cout<<"Vnesi ["<<i<<"]["<<j<<"]: ";
  14. cin>>niza[i][j];
  15. }
  16. }
  17. cout<<"Od gore levo kon dole desno: \n";
  18. for(int b=0;b<n+n;b++){
  19. for(int i=0;i<n;i++){
  20. for(int j=0;j<n;j++){
  21. if(i+j==b){
  22. cout<<niza[i][j]<<" ";
  23. }
  24. }
  25. }
  26. cout<<endl;
  27. }
  28. cout<<"Od gore desno kon dole levo: \n";
  29. for(int b=n;b>=0;b--){
  30. for(int i=0;i<n;i++){
  31. for(int j=0;j<n;j++){
  32. if(i-j==b){
  33. cout<<niza[i][j]<<" ";
  34. }
  35. }
  36. }
  37. cout<<endl;
  38. }
  39. for(int b=n-1;b>0;b--){
  40. for(int i=0;i<n;i++){
  41. for(int j=0;j<n;j++){
  42. if(j-i==b){
  43. cout<<niza[i][j]<<" ";
  44. }
  45. }
  46. }
  47. cout<<endl;
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement