Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int potencija(int x)
- {
- int k;
- for(k=1; ; k++)
- {
- if((long)pow(2, k)==x ||(long)pow(3, k)==x) return 1;
- if((long)pow(2, k)>x && (long)pow(3, k)>x) break;
- }
- return 0;
- }
- int main(void)
- {
- int x, brojac=0, i, x_max;
- scanf("%d", &x);
- if(x==0)
- {
- printf("Prazan niz!\n");
- return 0;
- }
- for(i=1; ; i++)
- {
- if(potencija(x))
- {
- brojac++;
- if(brojac==1 || x>x_max) x_max=x; /*brojac==1 znaci:kad nadje prvi takav broj onda ga postavi na max*/
- }
- scanf("%d", &x);
- if(x==0) break;
- }
- if(brojac==0) printf("Nema takvih brojeva u nizu.\n");
- else
- {
- printf("ukupno=%d\n", brojac);
- printf("%d\n", x_max);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement