📜  gfg 循环数组旋转 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:55.999000             🧑  作者: Mango

代码示例1
# include  
using namespace std; 

void rotate(int arr[], int n) 
{ 
    int last = arr[n - 1], i; 
    for (i = n - 1; i > 0; i--) 
    arr[i] = arr[i - 1]; 
    arr[0] = last; 
} 


int main() 
{ 
    int arr[100], i; 
    int n, turns;

    cin >> n;

    for(i=0;i> turns;

    while(turns>=1){
        rotate(arr,n);
        turns--;
    }

    for(i=0;i