--- [プログラム4]  sections.c

    1	#include <stdio.h>
    2	#include <stdlib.h>
    3	#define MAX 50000000 /**/
    4	int *A;
    5	
    6	main()
    7	{
    8	  int i,s;
    9	  A=malloc(MAX*sizeof(int));
   10	  for(i = 0; i < MAX; i++) A[i] = i; /**/
   11	  s= sumx(A,MAX);
   12	  exit(s);
   13	}
   14	
   15	int sumx(int *a, int n)
   16	{
   17	  int i,j,s;
   18	#pragma omp parallel
   19	 {
   20	#pragma omp sections private(j,s,i)
   21	  {
   22	#pragma omp section
   23	   {/* section add */
   24	    for(j=1;j<10;j++){
   25	      for(s=0,i = 0; i < n; i++) s += a[i];
   26	      printf (" + = %d\n",s);
   27	    }
   28	   }
   29	#pragma omp section
   30	   {/* section sub */
   31	    for(j=1;j<10;j++){
   32	      for(s=0,i = 0; i < n; i++) s -= a[i];
   33	      printf (" - = %d\n",s);
   34	    }
   35	   }
   36	  }
   37	 }
   38	 return s;
   39	}
--- END
