Pp9

szlaczek

Pp9
Oct 16th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define N 6
  5. int main()
  6. {
  7. /* int tab[N][N],i,j,x;
  8. for(i=0;i<N;i++){
  9. for(j=0;j<N;j++){ tab[i][j]=i+j; <-znane wartosci tablicy
  10. printf("%d", tab[i][j]);}
  11. printf("\n");} */
  12.  
  13. int tab[N][N],i,j,x;
  14. srand(time(NULL));
  15. for(i=0;i<N;i++){
  16. for(j=0;j<N;j++){ tab[i][j]=rand()%10;
  17. printf("%d ", tab[i][j]);}
  18. printf("\n");}
  19. printf("\n");
  20.  
  21. for(x=1;x<=N;x++){
  22. if(x%2){
  23. for(i=N-1;i+1-x>=0;i--) printf("%d ", tab[i][i+1-x]);}
  24.  
  25. else for(i=0;x+i<N+1;i++) printf("%d ", tab[x-1+i][i]);
  26. printf("\n");
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment