解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int count=0,result=0; int[] num = new int[a]; for (int i = 0; i < num.length; i++) { num[i] = sc.nextInt(); } while (result==0) { result=1; for (int i = 0; i < num.length; i++) { num[i] = num[i] / 2; } int t = num[0]; for (int i = 0; i < num.length; i++) { if (i == a - 1) { num[i] = num[i] + t; } else { num[i] = num[i] + num[i + 1]; } } for (int i = 0; i < num.length; i++) { if (num[i]%2!=0) { num[i]++; count++; } } for (int i = 0; i < num.length-1; i++) { if (num[i]!=num[i+1]) { result=0; break; } } if (result!=0) { System.out.println(count); } } } }
0.0分
0 人评分
【回文数(二)】 (C++代码)浏览:875 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:905 |
C语言训练-阶乘和数* (C语言代码)-------- 呆板写法浏览:1372 |
众数问题 (C语言代码)浏览:834 |
【金明的预算方案】 (C++代码)浏览:843 |
循环入门练习6 (C语言代码)浏览:971 |
1035 题解浏览:786 |
矩阵的对角线之和 (C语言代码)浏览:1359 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:597 |
简单的a+b (C语言代码)浏览:590 |