fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin >> n;
  8.  
  9. for (int i = 1; i <= n; i++) {
  10. int sum = 0;
  11.  
  12. for (int j = 1; j <= i; j++) {
  13. cout << j;
  14. sum += j;
  15.  
  16. if (j != i) {
  17. cout << "+";
  18. }
  19. }
  20.  
  21. cout << "=" << sum << endl;
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5316KB
stdin
3
stdout
1=1
1+2=3
1+2+3=6