Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <fcntl.h>
  4. #include <unistd.h>
  5. #include <sys/wait.h>
  6. #include <sys/types.h>
  7. int
  8. main(void)
  9. {
  10. int n;
  11. scanf("%d", &n);
  12. for(int i = 1; i <= n; i++) {
  13. printf("%d ", i);
  14. fflush(stdout);
  15. if(fork()) {
  16. wait(NULL);
  17. return 0;
  18. }
  19. if(i <> n) {
  20. printf(" ");
  21. } else {
  22. printf("\n");
  23. }
  24. }
  25. printf("\n");
  26. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement