201803-1 跳一跳
作者:互联网
题目:http://118.190.20.162/home.page
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,count=0,ans=0;//count记录2的个数
// freopen("in.txt","r",stdin); //输入重定向,输入数据将从in.txt文件中读取
cin>>x;
while(x)
{
if(x==1)
{
ans+=1;
count=0;
}
else if(x==2)
{
count++;
ans=ans+2*count;
}
cin>>x;
}
cout<<ans;
//fclose(stdin);
return 0;
}
标签:count,int,cin,ans,txt,201803,输入 来源: https://blog.csdn.net/han29_/article/details/120139374