Advertisement
brsjak

Ciklicno pomestuvanje - SP Lab 4

Oct 25th, 2016
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3.     int n, m, i, j;
  4.     scanf("%d",&n);
  5.     int a[n], b[n];
  6.     for(i=0;i<n;i++){
  7.         scanf("%d", &a[i]);
  8.     }
  9.     scanf("%d", &m);
  10.     m%=n;
  11.     if(m<0){
  12.         m+=n;
  13.     }
  14.     for(i=0;i<n;i++){
  15.         int index=(i+m)%n;
  16.         b[index]=a[i];
  17.     }
  18.     for(i=0;i<n;i++){
  19.         printf("%d ",b[i]);
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement