Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int funkcja (int a)
  5. {
  6. int i, suma=1;
  7. for (i=1; i<a; i++)
  8. {
  9. if (a%i==0)
  10. suma=suma+1;
  11. }
  12. if (suma<3)
  13. return 1;
  14. else
  15. return 0;
  16. }
  17.  
  18. int przedzial (int b, int c)
  19. {
  20. int j, suma2=1, k;
  21. for (j=b; j<=c; j++)
  22. {
  23. for (k=1; k<j; k++)
  24. {
  25. if (j%k==0)
  26. suma2=suma2+1;
  27. }
  28. if (suma2>2)
  29. }
  30. return 0;
  31. }
  32.  
  33.  
  34. int main(int argc, char *argv[])
  35. {
  36. int n;
  37. printf("sprawdzenie liczb (1) czy przedzial (2)?\n");
  38. scanf("%d", &n);
  39. if (n==1)
  40. {
  41. int a;
  42. printf("Podaj liczbe\n");
  43. scanf("%d", &a);
  44. printf("%d", funkcja(a));
  45. }
  46. if (n==2)
  47. {
  48. int b, c;
  49. printf("Podaj przedzial\n");
  50. scanf("%d", &b);
  51. scanf("%d", &c);
  52. printf("%d", przedzial(b, c));
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement