码迷,mamicode.com
首页 > 编程语言 > 详细

数组元素循环右移及静态链表

时间:2016-11-30 22:54:01      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:ret   turn   scan   targe   span   nbsp   static   math.h   ref   

1. 静态链表

https://github.com/BodhiXing/Data_Structure/tree/master/StaticListDemo

2. 数组元素循环右移

https://pta.patest.cn/pta/test/17/exam/4/question/262

思路:不做循环,只是换方式打印输出。

 1 #include <stdio.h>
 2 #include <math.h>
 3 
 4 
 5 int main() {
 6     int n,m,i;
 7     scanf("%d %d",&n,&m);
 8     int a[n];
 9     for(i=0; i<n; i++)
10         scanf("%d",&a[i]);
11     //M>N
12     while(m>=n)
13         m %= n;
14     for(i=n-m; i<n; i++)
15         printf("%d ",a[i]);
16     for(i=0; i<n-m-1; i++) {
17         printf("%d ",a[i]);
18     }
19     //注意:序列结尾不能有多余空格 
20     printf("%d",a[i]);
21     return 0;
22 }

 

数组元素循环右移及静态链表

标签:ret   turn   scan   targe   span   nbsp   static   math.h   ref   

原文地址:http://www.cnblogs.com/boyiliushui/p/6119699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!