Advertisement
Jobjob

OS Examen Janvier 2011 Q1

Dec 25th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.     int pid = fork();
  5.     if(pid == 0){ // le fils
  6.         system("ls -1 | wc -l > /tmp/compte.data");
  7.     } else{ // le pere
  8.         int i = 1;
  9.         float x = 0;
  10.         while(i<=1000){
  11.             if(i%2 == 1) x = x+1.0/i;
  12.             else x = x-1.0/i;
  13.             i++;
  14.         }
  15.         printf("La serie: %f\n",x);
  16.         system("x=$(cat /tmp/compte.data); echo Le repertoire courant contient $x fichiers.");
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement