#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int x;
int i=0;
int arr[30];
while(cin>>x){
if(x!=0){
arr[i++]=x;
}
else{
break;
}
}
int temp=0;
int sum=0;
for(int j=0;j<i;j++){
if(arr[j]==1){
sum+=1;
temp=0;
}
else{
if(temp==0){
temp=2;
sum+=temp;
}
else{
temp+=2;
sum+=temp;
}
}
}
cout<<sum;
return 0;
}
CCF-CSP201803-1跳一跳
最新推荐文章于 2024-05-06 10:59:23 发布