我一次性AC这道题,用时15分钟;
#include<iostream>
using namespace std;
int main()
{
//freopen("xxx.in","r",stdin);
//freopen("yyy.out","w",stdout);
int a,b,t;
cin >> a >> b;
int sum=0;
while(a>0 && b>0)
{
if(a>b)
{
t=a;
a=b;
b=t;
}
sum=0;
for(int i=a;i<=b;i++)
{
cout << i << " ";
sum=sum+i;
}
cout << "Sum=" << sum << '\n';
cin >> a >> b;
}
//fclose(stdin);
//fclose(stdout);
return 0;
}