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/02.c
T
2025-04-13 21:48:15 +03:00

36 lines
545 B
C
Executable File

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wait.h>
#include <sys/types.h>
int
main()
{
pid_t pid;
pid = fork();
if (!pid) {
pid = fork();
if (!pid) {
printf("3 ");
return 0;
} else if (pid == -1) {
return 1;
} else {
wait(NULL);
printf("2 ");
}
return 0;
} else if (pid == -1) {
return 1;
} else {
wait(NULL);
printf("1");
}
printf("\n");
return 0;
}