fork download
  1. #include<stdio.h>
  2. //#pragma warning(disable:4996)
  3.  
  4. int ADD( int operand1, int operand2 );
  5.  
  6. int ADD( int operand1, int operand2 )
  7. {
  8. return operand1 + operand2; // 대입은 왜하냐구 그냥 더하면 되지.
  9. }
  10.  
  11. int main()
  12. {
  13. char command;
  14. int operand, result; // 덧셈만 할건 아니잖아?
  15.  
  16. scanf( "%c", &command );
  17. switch(command)
  18. {
  19. case '+':
  20. scanf( "%d", &result );
  21. while( 1 )
  22. {
  23. scanf( "%d", &operand );
  24. if( operand == 0 ) break;
  25. result = ADD( result, operand );
  26. printf( "%d\n", result );
  27. }
  28. break;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 2160KB
stdin
+
1
2
3
4
5
0
stdout
3
6
10
15