Advertisement
MosTzz

Numar prim

Jan 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // Numar prim.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. int val;
  6.  
  7. int prim(int n)
  8. {
  9. bool a;
  10. _asm {
  11. mov eax, n
  12. mov esi, 2 //d
  13. i_for:
  14. cmp esi, eax
  15. ja afara
  16. mov edx, 0
  17. div esi
  18. cmp edx, 0
  19. jne e1
  20. mov a, 0
  21. e1:
  22. inc esi
  23. jmp i_for
  24. afara :
  25. }
  26. if (a == 0)
  27. return 0;
  28. return 1;
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35. int main()
  36. {
  37. int n;
  38.  
  39. printf("n="); scanf_s("%d",&n);
  40. if (prim(n) == 1)
  41. printf("Este numar prim\n");
  42. else
  43. printf("Nu este numar prim\n");
  44. return 1;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement