zoi20

Untitled

Feb 8th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int djeljiv_sa_tli(int n)
  4. {
  5.     int cifra[50];
  6.     int brojac=0,k=1,broj=n,i,novibroj=0,j,m=1;
  7.     while(n!=0)
  8.     {
  9.         n/=10;
  10.         brojac++;
  11.     }
  12.     n=broj;
  13.     for(i=0;i<brojac;i++)
  14.     {
  15.         cifra[i]=n%10;
  16.         if(cifra[i]%3==0) cifra[i]=0;
  17.         novibroj+=cifra[i]*k;
  18.         k*=10;
  19.         n/=10;
  20.  
  21.     }
  22.  
  23.     for(i=0;i<brojac;i++)
  24.     {
  25.         cifra[i]=novibroj%10;
  26.         if(cifra[i]!=0)
  27.         j+=cifra[i]*m;
  28.         m*=10;
  29.         novibroj/10;
  30.     }
  31.     return j;
  32. }
  33.  
  34.  
  35. int main()
  36. {
  37.     int x;
  38.     printf("unesi broj:");
  39.     scanf("%d",&x);
  40.     printf("%d",djeljiv_sa_tli(x));
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment