Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int jePrvoc(int y);
- int main()
- {
- int x, y, i, j, k, xIndex, *xDelitele;
- printf("Zadej cislo: ");
- scanf("%d", &x);
- xDelitele=NULL;
- xDelitele=(int *)malloc(sizeof(int)*x);
- xIndex = 0;
- for(i=1; i<=x; i++)
- {
- if (x%i==0)
- {
- xDelitele[xIndex] = i;
- xIndex++;
- }
- }
- printf("Pocet delitelu: %d\n", xIndex);
- printf("Delitele: ");
- for(j=0;j<xIndex;j++)
- {
- printf("%d ", xDelitele[j]);
- }
- printf("\nPrvociselny delitele: ");
- for(k=1;k<xIndex;k++);
- {
- y=xDelitele[k];
- if(jePrvoc(y)==1)
- {
- printf("%d ", y);
- }
- }
- printf("\n\n");
- free(xDelitele);
- return 0;
- }
- int jePrvoc(int y)
- {
- int l;
- for(l=2;l<y;l++)
- {
- if(y%l==0)
- {
- return 2;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement