This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cmc/3sem/cnts/contest11/04.c
T
2025-04-13 21:48:15 +03:00

39 lines
575 B
C
Executable File

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int
main()
{
pid_t pid;
int n;
if (scanf("%d", &n) != 1) {
return 1;
}
for (int i = 1; i <= n; i++) {
printf("%d", i);
fflush(stdout);
if (i == n) {
printf("\n");
return 0;
} else {
printf(" ");
fflush(stdout);
}
pid = fork();
if (!pid) {
continue;
} else {
wait(NULL);
return 0;
}
}
return 0;
}