#include<iostream> using namespace std; int main() { int n; cin>>n; int sum=0; int point=0; while(n!=0) { if(n==2) point+=2; else point=0; switch(n){ case 1:sum+=1;break; case 2:sum+=point; } cin>>n; } cout<<sum<<endl; return 0; }
#include<iostream> using namespace std; int main() { int n; cin>>n; int sum=0; int point=0; while(n!=0) { if(n==2) point+=2; else point=0; switch(n){ case 1:sum+=1;break; case 2:sum+=point; } cin>>n; } cout<<sum<<endl; return 0; }
转载于:https://www.cnblogs.com/WuDie/p/11287926.html