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