2009-01-15 16:42:45來源不明
2008 NPSC C. 電費系統
/*************************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- main()
- {
- int a,b,n,N,temp=0;
- int x[51];
- while(scanf("%d",&n)==1&&n!=0)
- {
- temp=0;
- for(a=0;a<n;a++)
- {
- scanf("%d",&N);
- x[a]=N;
- }
- for(b=1;b<n;b++)
- {
- if(x[b-1]<x[b])
- temp=temp+(x[b]-x[b-1])*20;
- else if (x[b-1]>x[b])
- temp=temp+(x[b-1]-x[b])*10;
- else
- temp=temp;
- }
- printf("%d\n",temp);
- }
- return 0;
- }
下一篇:2008 NPSC D. 沙之國