Love丶FFC's Blog
给定一个整数数列,数列中连续相同的最长整数序列算成一段,问数列中共有多少段?
输入的第一行包含一个整数n,表示数列中整数的个数。
第二行包含n个整数a1, a2, …, an,表示给定的数列,相邻的整数之间用一个空格分隔。
输出一个整数,表示给定的数列有多个段。
8
8 8 8 0 12 12 8 0
5
8 8 8是第一段,0是第二段,12 12是第三段,倒数第二个整数8是第四段,最后一个0是第五段。
1 ≤ n ≤ 1000,0 ≤ ai ≤ 1000。
1.判断是否与前一个数相同,如不同则计数。
package CCF_CSP; import java.util.Scanner; public class _20150901_100point { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); //整数的个数 int[] num = new int[n]; //数列 int count = 1; for(int i=0;i<n;i++) { num[i] = scanner.nextInt(); if(i > 0 && num[i] != num[i-1]) //该整数非第一个整数且与前一个整数不同 { count++; } } System.out.println(count); } }
Abupguele
Hypothalamic pituitary thyroidal function in eumenorrheic and amenorrheic athletes generic for cialis
Outlils
There may still be some inflammation after those four days, but it typically resolves after a month cialis online prescription
invoimi
eCoefficient represents a multiplicative change in hormone level for an IQR change in phthalate metabolite concentration after back- transformation of both hormone and phthalate metabolite concentrations; for an IQR change in phthalate metabolite concentration, a coefficient equal to 1 propecia
invoimi
buy cialis with paypal ketoconazole will increase the level or effect of lumefantrine by affecting hepatic intestinal enzyme CYP3A4 metabolism
PRwgUSG
Krausz C, Hoefsloot L, Simoni M, TГјttelmann F cialis daily Based on the old adage strength in numbers, Legal Services of Southern Piedmont, NC Child, and the American Heart Association would like to convene those working on expansion to share updates on our individual advocacy efforts and develop synergy as a collaborative group