TA的每日心情 | 开心 2014-6-18 08:29 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
滴水大师
 
- 积分
- 2345
|
题目
解决代码及点评
- <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">#include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- const int N = 20;
- int a[N] = {20,1,8,4,13,6,10,15,2,17,3,19,7,16,8,11,14,9,12,5}; // 外圈数组
- int b[N]; // 和数组
- ///相邻四个数之和,放入b[N]
- for (int i = 0; i < N; i++) // i代表内圈数组
- {
- b = a + a[(i + 1) % N] + a[(i + 2) % N] + a[(i + 3) % N]; // 求响铃的四位数之和
- }
- int index = 0;
- int max = b[index];
- //求b[N]中最大值
- for (int i = 1; i < N; i++)
- {
- if (b > max)
- {
- max = b;
- index = i;
- }
- }
- printf("index = %d,max = %d\n",index + 1,max);
- system("pause");
- }</pre><br><br></pre></pre>
|
|