Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- int mode = 0;
- void
- sigint_handler(int signo)
- {
- mode = 0;
- signal(SIGINT, sigint_handler);
- }
- void
- sigquit_handler(int signo)
- {
- mode = 1;
- signal(SIGQUIT, sigquit_handler);
- }
- int
- main(void)
- {
- signal(SIGINT, sigint_handler);
- signal(SIGQUIT, sigquit_handler);
- printf("%d\n", getpid());
- int res = 0;
- int curr;
- while (scanf("%d", &curr) == 1) {
- res = mode ? res * curr : res + curr;
- printf("%d\n", res);
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment