求助!!!如何做到结果比较输出???c++小白只输出一组数据
c吧
全部回复
仅看楼主
level 2
求助!!!
如何做到结果比较输出???
c++小白
只输出一组数据的结果我是可以的,但这看不明白[乖][乖][乖][乖]
2021年11月16日 15点11分 1
level 2
#include<iostream>
using namespace std;
int main()
{
int a[100];
int sum[100];
int total=0;
int score=0;
for(int i=0;a[i]!=0;i++)
{
if(a[i]==1)
{
score=1;
total+=score;
}
if(a[i]==2)
{
if(i==0)
{
score=2;
total+=score;
}
else
{
if(score==1)score=2;
else score=score+2;
total+=score;
}
}
}
cout<<total;
}
2021年11月16日 15点11分 2
level 2
目前只能打成这样[小乖]
2021年11月16日 15点11分 3
level 8
欢迎进来一起学习交流讨论
2021年12月13日 07点12分 4
1