#include<iostream>
using namespace std;
int main()
{
int i,j,s1=0,s2=0;
int i1,j1;
int sign=-1;
cout << "请输入起始值bg:";
cin >> i;
cout << "请输入终止值end:";
cin >> j;
i1=i;j1=i+1;
while (i1 <= j)
{
s1+=i1;
i1=i1+2;
}
while(j1<= j)
{
s2+=j1;
j1=j1+2;
}
cout << "sum=";
for(i1=i;i1<j;++i1)
{
cout << i1;
if(sign == -1)
cout << '-';
else
cout << '+';
sign*=-1;
}
cout << j << '=' << s1-s2 << endl;
return 0;
}
追问谢谢