Advertisement
azg2017

Untitled

Jun 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. package geometrics;
  2.  
  3. public class rotate {
  4. public static int[] rotate(int[] v, int n) {
  5. int result[] = new int [v.length];
  6. int count=0;
  7. while(n>count) {
  8. int first = v[0];
  9. for (int i = 0; i < v.length - 1; i++) {
  10. v[i] = v[i + 1];
  11. }
  12. v[v.length - 1] = first;
  13. count++;
  14. }
  15. return v;
  16. }
  17.  
  18. public static void main(String[] args){
  19. int[] v={1,2,3};
  20. int[] result = rotate(v,3);
  21. for(int i=0;i<result.length;i++){
  22. System.out.print(result[i]);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement