Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- int Sprawdz(int x) {
- int i;
- for(i=2; i<x; ++i) {
- if(x==i) continue;
- if(x%i == 0) return 0;
- }
- return 1;
- }
- int main(void)
- {
- FILE *plik = open("wyniki.txt", "w+");
- if(!plik) return 0;
- int i;
- int foo = fork();
- if(foo) {
- for(i=2; i<=100; ++i) {
- if(Sprawdz(i)) {
- fprintf(plik, "%d \n", i);
- }
- }
- }
- if(foo==0) {
- for(i=100; i<=200; ++i) {
- if(Sprawdz(i)) {
- fprintf(plik, "%d \n", i);
- }
- }
- }
- if(foo) {
- int buff;
- fseek(plik, 0, SEEK_SET);
- while(!feof(plik)) {
- fscanf(plik, "%d", &buff);
- printf("%d \n", buff");
- }
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement