fork download
  1. #include <stdio.h>
  2.  
  3. void hoge(int n, int m) {
  4. int sum = 0;
  5. int start, end;
  6.  
  7. if (n < m) {
  8. start = n;
  9. } else {
  10. start = m;
  11. }
  12.  
  13. if (n > m) {
  14. end = n;
  15. } else {
  16. end = m;
  17. }
  18.  
  19. for (int i = start; i <= end; i++) {
  20. sum += i;
  21. printf("%d", i);
  22. if (i < end) {
  23. printf("+");
  24. }
  25. }
  26.  
  27. printf("=%d", sum);
  28. }
  29.  
  30. int main() {
  31. hoge(4, 8);
  32. return 0;
  33. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
4+5+6+7+8=30