Guest User

pdp competition phase #1

a guest
Feb 28th, 2012
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int is_prime(int);
  4. int main(void)
  5. {
  6.   FILE* pfin = fopen("function.in","r");
  7.   FILE* pfout = fopen("function.out","w");
  8.   int N = 0,M = 0,K = 0,counter = 0;
  9.   fscanf(pfin,"%d %d",&N,&M);
  10.   fclose(pfin);
  11.   for(K=(N>M?M:N)+1; K<(N>M?N:M); K++){
  12.     if(is_prime(K) && K%2) {
  13.       if(!counter)  fprintf(pfout,"%d",K);
  14.       else fprintf(pfout," %d",K);
  15.       counter++;
  16.     }
  17.   }
  18.   if(counter)
  19.     fprintf(pfout,"\n");
  20.   fclose(pfout);
  21.   return 0;
  22. }
  23. int is_prime(int inum)
  24. {
  25.   for(int icounter=2; icounter<inum/2; icounter++){
  26.     if(!(inum%icounter))
  27.     return 0;
  28.     }
  29.   return 1;
  30. }
RAW Paste Data