您的位置:首页 > 编程语言 > C语言/C++

CSP考试 2015年9月第1题 数列分段 C语言实现

2016-03-24 18:54 411 查看


#include <stdio.h>
//#define NUM 8
main()
{
//int NUM=8;
int NUM;
scanf("%d",&NUM);
/*
if((NUM<1)||(NUM>1000))
{
printf("erro\n");
}*/
//printf("NUM=%d\n",NUM);
int a[NUM];
int i;
for(i=0;i<NUM;i++)
{
scanf("%d",&a[i]);/*
if((a[i]<0)||(a[i]>1000))
{
printf("a[%d] erro\n",i);
}*/
}
//printf("please input:\n");
//scanf("*%d",a[0]);
/*
for(i=0;i<8;i++)
{
scanf(" %d",a[i]);
}*/

/*(
a[0]=8;
a[1]=8;
a[2]=8;
a[3]=0;
a[4]=12;
a[5]=12;
a[6]=8;
a[7]=0;
*/

int hello =1;
int temp=a[0];
for(i=0;i<NUM;i++)
{
//printf("The numbe %d.\n",i);
//printf("The numbe %d is %d.\n",i,a[i]);
if(a[i]==temp)
{
continue;
}
hello++;
temp=a[i];
}
printf("%d\n",hello);
//system("pause");
}




                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: