Advertisement
VitorMDias

gold

Sep 1st, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <ctype.h>
  6.  
  7. int primo(n)
  8. {
  9.     int i , p=0;
  10.     for(i = 1; i <= n ; i++)
  11.         {
  12.             if ((n % i) == 0 && n != 1)
  13.                 p ++;
  14.         }
  15.     if(p == 2)
  16.         return 1;
  17.     else
  18.         return 0;
  19.     p = 0;
  20. }
  21.  
  22. int main()
  23. {
  24.     int n , r1 , r2;
  25.     int aux1 , aux2 , flag=0;
  26.     do
  27.     {
  28.         aux1 = aux2 = flag = 0;
  29.         scanf("%d" , &n);
  30.         if(n == 0)
  31.             break;
  32.         if(n % 2 != 0 && n > 1)
  33.             printf("erro\n");
  34.         else if(n > 2 && n < 1000000)
  35.         {
  36.            
  37.             aux1 = n;
  38.             aux2 = 0;
  39.             while(flag == 0)
  40.             {
  41.                 aux1--;
  42.                 aux2++;
  43.                 if(primo(aux1) == 1 && primo(aux2) == 1 )
  44.                     flag = 1;
  45.             }
  46.             if(aux1 + aux2 == n)
  47.                 printf("%d %d\n" , aux2 , aux1);
  48.         }
  49.        
  50.        
  51.     }while(n != 0);
  52.    
  53.    
  54.    
  55.    
  56.    
  57.    
  58.    
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement