PAT_1008(中文)_数组元素循环右移问题
题目地址:http://pat.zju.edu.cn/contests/pat-b-practise/1008
1 #include<stdio.h> 2 3 int n; 4 int m; 5 int num[105]; 6 int i; 7 int count = 0; 8 int main() 9 { 10 scanf("%d%d", &n, &m); 11 m = n - m % n; 12 for( i = 0; i < n; ++i ) 13 { 14 scanf( "%d", &num[i] ); 15 } 16 for( i = m; i < n; ++i ) 17 { 18 printf("%d", num[i]); 19 ++count; 20 if( count != n ) 21 { 22 printf(" "); 23 } 24 } 25 for( i = 0; i < m; ++i ) 26 { 27 printf("%d", num[i]); 28 ++count; 29 if( count != n ) 30 { 31 printf(" "); 32 } 33 } 34 printf("\n"); 35 }