fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. int a , b , tot=0;
  5. cin >> a >> b;
  6. for(int i=a ; i<=b ; ++i){
  7. cout << i << "+="[i==b],tot+=i;
  8. }
  9. cout << tot;
  10. }
Success #stdin #stdout 0s 4524KB
stdin
1 7
stdout
1+2+3+4+5+6+7=28